0

I have a UITableView (which is a UIScrollView) that's managed by a UITableViewController set up in Interface Builder. The table view has more content than can fit on screen at once, so it's scrollable. However, I would like to prevent the table view contents from appearing at the top of the screen when scrolling - the top 50 pts needs to be reserved for another element. I can set the contentInset which will move the content down, but this does not prevent it from displaying the content in that area - when you scroll the content moves up to that area.

The question is, how can you always prevent content from appearing at the top? It'd be easy to move the entire table view down, however I cannot do that, as I need the table view to continue to fill the entire screen. I also can't just set the contentInset then display a solid UIView at the top that covers up the scrolling content, I need to prevent it from appearing in that space entirely because that element at the top has transparency. I am wondering if there is a way to specify the bounds or an inset for only the scrollable area, so once content reaches that invisible limit it will disappear.

A picture can explain what I'm trying to obtain a lot better I'm sure: enter image description here

Note that the red frame is not a subview of the table view - it's always fixed to the top of screen. I already have the blue and red frames set up, the question is how to restrict the scrollable content to the purple frame? Currently a purple frame does not exist, as it fills the entire display therefore showing up underneath the red frame.

This is the overall goal, what I am trying to obtain.

Community
  • 1
  • 1
Jordan H
  • 52,571
  • 37
  • 201
  • 351
  • have only one section in the table view and set the height of the section header to 50 pixels. If you want to add ui elements in the top 50 pixels use viewForHeaderInSection method of the table view – Ratikanta Patra Dec 05 '14 at 06:43
  • @RatikantaPatra The view at the top is fixed, shouldn't scroll with the table (it's actually a nav bar). I've already got that in place, just trying to figure out the scrolling. – Jordan H Dec 05 '14 at 06:47
  • If you have UITableView with style plain, the header will be fixed at 50 pixels and will always be visible and moreover the content will always scroll below that header – Ratikanta Patra Dec 05 '14 at 06:49
  • @RatikantaPatra Interesting, didn't know that. But this is actually a grouped table view style. – Jordan H Dec 05 '14 at 06:51
  • if UITableViewStylePlain suits your requirement,I would recommend try that – Ratikanta Patra Dec 05 '14 at 06:53
  • @RatikantaPatra Unfortunately, plain style won't do, it's very much a group layout with several sections. Static content, but organized in groups. – Jordan H Dec 05 '14 at 06:56

0 Answers0