Scroll TableView and an Example Views all together

I have two Views and one tableView beneath them. I want to scroll on all of them like apple iTunes Appstore app. (when I scroll down, those two views should disappear).
I take 2 approaches:
1-set table view’s scroll enabled property to OFF and place all 3 views in a scrollView. but the problem is my TableView’s height is dynamic and scrollView should know about its exact height.
2-set those 2 views as my tableView’s HeaderView but I don’t know how to implement this between storyboard’s view and code.
Any helps would be so appreciated.

Take a look at your storyboard. From the Object Library, you can drag a View (UIView) to just above your prototype cells. That view then becomes your table view header. Once you’ve done that, you can move your two views into the table header view and then change the table view to use the entire display. The table view header will scroll off the screen when you scroll down.

Have fun!

2 Likes

Thanks for your helpfull answer :heart_eyes: :pray:. It works nice but now I have problem with my other CollectionViewController to do the same. Unfortunateley I cann’t add view to my collectionView header in IB.:frowning2:

How many sections do you have in your collection view? If there is only one, you could create a section header and put your two views in there.

I have :

  • View
  • CollectionView(1setion-Horizental Scrolling)
  • CollectionView(1section-Vertical Scrolling)


    I jus want to scroll in all these views.
    What is the best approach to implement this?
    When I tried to put my Carousel View subview of Collection View Header I get this error:
    The liveCarousel outlet from the LiveViewController to the iCarousel is invalid. Outlets cannot be connected to repeating content.
    I think I can use nested collectionViews in TableView cells but after that the problem is how set last TableView’s cell’s height dynamic(equal with collectionView’s height)