3

I have set up my UISearchBar (using UISearchController) iOS8 standards, and I'm adding it programmatically to my UIViewController above my UITableView (believe that's the only way to do it for iOS8 at the moment) like so in my viewDidLoad (unlike all other tutorials where they add it in their TableView header) I wanted mine to stick when scrolling my UITableView:

self.automaticallyAdjustsScrollViewInsets = NO;
UITableViewController *searchResultsController = [[UITableViewController alloc] initWithStyle:UITableViewStylePlain];
searchResultsController.tableView.dataSource = self;
searchResultsController.tableView.delegate = self;
CGRect frame = [[UIScreen mainScreen] applicationFrame];
CGSize size = frame.size;
self.searchController = [[UISearchController alloc] initWithSearchResultsController:searchResultsController];

self.searchController.searchResultsUpdater = self;
self.searchController.searchBar.frame = CGRectMake(0, 60, size.width, 44.0);
self.definesPresentationContext = YES;

[self.view addSubview:self.searchController.searchBar];

The issue I'm having is that when I click in my search field it disappears behind my UINavigationBar by transitioning up, which normally wouldn't happen if in the header of a UITableView.

Is there anyway to stop this from happening? Thank you!

Substantial
  • 6,684
  • 2
  • 31
  • 40
Joey
  • 221
  • 3
  • 10

1 Answers1

0

In the storyboard select the corresponding viewcontroller -> Attributes.

Tick all the three extended edges (Under Top Bars, Under Bottom Bars, Under Opaque Bars) enter image description here

Manvik
  • 977
  • 14
  • 26