2
votes

I have a UITableView in a controller that is nested under a UITabBar.

The interaction is all wired up in Interface Builder so far, nothing done programmatically in terms of view switching.

I've added a UISearchDisplayController as the header of my UITableView. It displays fine, and when I tap on the text entry area, the cancel button appears and the black overlay flies in.

However, the keyboard never appears and when tapping the cancel button, the overlay flies out and the cancel button disappears, but the text entry area keeps focus and the caret stays flashing there, so I cannot tap there again to re-display the search results.

So essentially I have two problems:

  1. Keyboard not appearing when starting to edit text on UISearchBar from UISearchDisplayController

  2. UISearchBar not loosing focus when cancel button is tapped.

What am I doing wrong?

2
have You set the delegate property? - Mudit Bajpai
I've dragged and dropped it. The delegate is assigned in the IB to be the containing view controller. Would not having the delegate correct cause these symptoms? - Robert Fall

2 Answers

1
votes

The .xib file that had my tab bar in it contained a UIWindow.

This lead to all sorts of craziness and in the end I gave up on trying to do this with interface builder, and resorted to constructing the UITabBar in code, thereby not creating a second UIWindow.

This resolved the problems and the UISearchDisplayController behaved correctly.

0
votes

check this method in UISearchBarDelegate:

- (void)searchBarCancelButtonClicked:(UISearchBar *) searchBar;

Try to see if this is getting called and do keyboard-related removal in here. If not, try making another UISearchDisplayController. (I actually never use the default viewController's one). Also, make sure the delegate is correctly set.