UISearchDisplayController not displaying keyboard when text area touched

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:

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

  • UISearchBar not loosing focus when cancel button is tapped.

  • What am I doing wrong?


    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.


    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.

    链接地址: http://www.djcxy.com/p/44238.html

    上一篇: 停止UISearchDisplayController关闭搜索栏键盘

    下一篇: 当文本区域被触摸时,UISearchDisplayController不显示键盘