2

I am developing a table view where the header of the first section of a needs to be fixed at point. I have set table view style as Plain. The section header is now fixed upto the point where the user scrolls in section 0. As soon as section 1 appears the header also scrolls up. Is there any way that the header of section 0 should always be fixed to the top?

Thanks in advance!

user2604897
  • 193
  • 1
  • 3
  • 13
  • 1
    You can implement it as a fixed view, which is a sibling of your tableView if you don't want the header to be moved at all. – alexburtnik Oct 20 '16 at 13:36
  • I'm not sure what you're trying to achieve so perhaps an edit is needed. However, it sounds like this isn't a good fit for UITableView. Messing with the scrolling mechanism of UITableView, if possible, would be very hard and introduce other challenges. Perhaps this is better done using tabs? – Roy Falk Oct 20 '16 at 14:03
  • Yes i do not want it to be moved at all. So I have created a xib file for the header. How can i refer that and add as header to my table – user2604897 Oct 21 '16 at 04:14

1 Answers1

0

You should add UIView which looks like header and it will be at fix top position and after that view add tableview so when you scroll your UIView will not affected and remains at same position. So, you can manage your stuff like this!

Ketan Parmar
  • 27,092
  • 9
  • 50
  • 75
  • Okay. But I have a xib for the view that i need as header. How can i access that in my view controller file – user2604897 Oct 21 '16 at 04:13
  • [http://stackoverflow.com/questions/863321/how-to-load-a-uiview-using-a-nib-file-created-with-interface-builder](http://stackoverflow.com/questions/863321/how-to-load-a-uiview-using-a-nib-file-created-with-interface-builder) – Ketan Parmar Oct 21 '16 at 04:46
  • Thanks! But on doing this , my header is still scrolling... :( – user2604897 Oct 21 '16 at 07:01