searchBarSearchButtonClicked of UISearchBar does not cancel the input mode

This code works

 public func searchBarSearchButtonClicked(searchBar: UISearchBar) {
print("search")
}

But if keyboard search button is pressed the UISearchBar is still active. To deactivate I have to press 'cancel' button. What have I missed?

Screenshot

在这里输入图像描述


以下解决了这个问题:

self.searchController?.active = false;

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

上一篇: UITextField和UITextView的内容到NSString

下一篇: searchBarSearchButtonClicked UISearchBar不会取消输入模式