1

I wonder if its possible to add a view under the navigation bar in a UITableViewController?

What I would like to do is to add a view under the navigation bar in my UITableViewController so that I can add a search input / filter button to that view. But I want the view to have a fixed position under the navigation bar so that I can hide the navigationbar+view when swiping.

Right now storyboard only lets me add a view in the UITableViewController. And the new view is also swipeable. And the loading indicator shows up above the view when you swipe down.

enter image description here

Nat
  • 12,032
  • 9
  • 56
  • 103
user2722667
  • 8,195
  • 14
  • 52
  • 100
  • Just put it in the header view, that's what they are for. – Dreaming In Binary Aug 04 '15 at 13:39
  • @DreamingInBinary what do you mean with header view? My navigation bar has an image in the center that you cant see on the image I provided. So I cant add any more items in the navigation bar. (New to ios-dev) – user2722667 Aug 04 '15 at 13:47
  • It means the header view of `UITableView`. Do not confuse with `sectionHeaderView`. – Nat Aug 04 '15 at 13:51
  • @Vive Sorry I only know of sectionHeaderView, do you have link / tutorial on this that I could check out? Thanks – user2722667 Aug 04 '15 at 14:17
  • Are you planning on using UISearchController? Or something custom? – MÖRK Aug 04 '15 at 15:34
  • @MarkBlythe something custom – user2722667 Aug 04 '15 at 15:39
  • `self.tableView.tableHeaderView = self.searchController.searchBar;` I use this for search controller but if you are using a custom view it should be possible in a similar way. Replace `self.searchController.searchBar` with your custom search view. This adds it to the table header which looking at your screenshot should be right below the navigation bar. – MÖRK Aug 04 '15 at 15:42
  • OR Add a UIToolBar and customise that. [link](http://stackoverflow.com/questions/21407977/whats-the-best-way-to-add-a-view-under-uinavigationbar-in-ios7) – MÖRK Aug 04 '15 at 15:52
  • @MarkBlythe thanks alot! But the problem now is that the new item added will appear under the refreshControl. I would like it to be sticky/fixed under the navigation bar. Is this possible? I have alot of stuff going on so I would really not have to rewrite all - a solution is to have a view controller wrap a table view or embedd the table view VC inside a container view in the root VC – user2722667 Aug 04 '15 at 16:31
  • You should take a look into `UISearchController`, it will solve your problems. – Nat Aug 04 '15 at 17:10
  • @Vive the UISearchController will scroll with the table view I want it to be fixed under the navigation bar – user2722667 Aug 04 '15 at 17:28
  • UIToolbar should be fixed to navigation bar. The refresh control should be just below that. – MÖRK Aug 04 '15 at 18:02
  • I don't understand how do you want it to act. When you pull up it should both refresh and show the search bar? Or it should guess what user wants to do? Both sounds like a wrong UX and I'd reconsider this in your place :). Cheers. – Nat Aug 05 '15 at 13:53

0 Answers0