UINavigationBar 中的 UISearchBar 无法添加 UIBarButtonItem [英] UISearchBar in UINavigationBar can't add UIBarButtonItem
问题描述
我正在尝试使用 self.searchDisplayController.displaysSearchBarInNavigationBar = YES;
UISearchBar 被很好地添加到 UINavigationBar 中,但左/右 UIBarButtons 不见了.我就是不知道如何添加它们.
The UISearchBar gets added quite well into the UINavigationBar, but the left/right UIBarButtons are gone. I just can't figure out how to add them.
安迪对此有何想法或示例?
Andy ideas or examples on this?
推荐答案
我的愚蠢错误.当使用 self.searchDisplayController.displaysSearchBarInNavigationBar = YES;
你需要使用 self.searchDisplayController.navigationItem
添加 UIBarButtons.现在它工作正常.
Dumb error from mine. When using self.searchDisplayController.displaysSearchBarInNavigationBar = YES;
You need to use self.searchDisplayController.navigationItem
to add the UIBarButtons. Now it is working properly.
这篇关于UINavigationBar 中的 UISearchBar 无法添加 UIBarButtonItem的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!