Search code examples
iosiphoneobjective-cuisearchbaruisearchdisplaycontroller

make searchBar and searchDisplayController look like normal input field


I've got a search bar within a UITableView, but when I click the search bar, the UITableView takes up the entire space of the ViewController while it should always perform as a subview and stay in the width it was given. Secondly, I want to get the search bar to look like a normal input field as on paper: just a straight line underneath instead of borders all around.

It'd be great if somehow could answer both of the questions asked here.

I've included a visual for reference, the first is the view before, the other one when the UISearchBar is active.

1

enter image description here

2

enter image description here

Update

I've figured out how to stop the UITableView from going fullscreen, by replacing the UISearchDisplayController for a UISearchBar. However, now my search functionality does not work anymore.


Solution

  • Problem solved: in order to prevent the TableView from going fullscreen, I changed UISearchDisplayController for a UISearchBar and changed the delegate methods of search into: -(void)searchBar:(UISearchBar *)searchBar textDidChange:(NSString *)searchText