Dynamically Changing Keyboard Type for a UISearchBar

后端 未结 3 1150
轻奢々
轻奢々 2020-12-14 20:32

I have an iPhone app that uses a UISearchBar and UISearchDisplayController. The search bar has three scope buttons. I would like the keyboard to

3条回答
  •  情话喂你
    2020-12-14 20:35

    [searchBar reloadInputViews] 
    

    and

    [searchBar resignFirstResponder];
    [searchBar becomeFirstResponder];
    

    both can work, but the second method have more side effect, change firstResponder, can trigger keyboard's notification, so may affect other logic which depends on the keyboard's notification, and affect the view's frame which depend on keyboard frame's change

提交回复
热议问题