UINavigationBar 中的 UISearchBar 无法添加 UIBarButtonItem [英] UISearchBar in UINavigationBar can't add UIBarButtonItem

查看:31
本文介绍了UINavigationBar 中的 UISearchBar 无法添加 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屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆