2

I'm trying to create a UITableViewController in a storyboard with a UISearchBar and UISearchDisplayController.

I also want to use the displaysSearchBarInNavigationBar property of the UISearchDisplayController.

However, no matter what I do it is messing up the display of the table.

I was initially following this tutorial by AppCode but it doesn't use the navigation bar property.

Anyway, I stripped down the code to an absolute minimum that still fails.

You can see the gist.

When I run it it leaves a "ghost" search bar in the table. Like this...

enter image description here

This happens whether I push onto the current navigation controller or present with a new nag controller. Nothing works.

Storyboard on request...

Storyboard screenshot

It is just a plain UITableView subclass with a default style cell and and search bar. I haven't added anything else. (You can do the same following the AppCoda tutorial above). All I have added is the displaysSearchBarInNavigationBar code.

The two ways I have tried loading this.

First. As a modal view controller.

- (IBAction)userSearch
{
    UIStoryboard *storyboard = [UIStoryboard storyboardWithName:@"UserSearch" bundle:[NSBundle mainBundle]];
    UINavigationController *controller = [storyboard instantiateInitialViewController];
    [self presentViewController:controller animated:YES completion:nil];
}

Second. As a standard push.

- (IBAction)userSearch
{
    UIStoryboard *storyboard = [UIStoryboard storyboardWithName:@"UserSearch" bundle:[NSBundle mainBundle]];
    UINavigationController *controller = [storyboard instantiateInitialViewController];
    [self.navigationController pushViewController:controller.topViewController animated:YES];
}

I know this isn't the standard way to push a view controller using a nag controller I just wanted to check it wasn't the modal present. I am using a separate storyboard as there will potentially be a user flow through this. Also I tried a standard nib and that didn't work either.

Tried to code the UISearchDisplayController manually by overriding - (UISearchDisplayController *)searchDisplayController on the UITableViewController and that did the same thing.

Screenshots after moving the UISearchBar in the Storyboard navigator panel

No BG Color

Weird gap

Another weird gap

Fogmeister
  • 76,236
  • 42
  • 207
  • 306

0 Answers0