我有一个 UISearchDisplayController,它可以在我的一个 iOS6 应用程序中完美运行。现在,我想将这个应用程序迁移到iOS7。
我已阅读 Apple 文档,其中内容如下:
Starting in iOS 7.0, you can use a search display
controller with a navigation bar (an instance of
the UINavigationBar class) by configuring the
search display controller’s displaysSearchBarInNavigationBar
and navigationItem properties.
displaysSearchBarInNavigationBar 的设置非常简单。但我对 navigationItem 的唯一线索如下:
Important: The system raises an exception if you
attempt to set the titleView property for a search
display controller’s navigation item.
我似乎找不到如何设置导航项目的示例。如何让我的导航栏嵌入我的搜索栏?有人可以给我举个例子吗?
提前谢谢您!
最佳答案
UISearchDisplayController 创建并管理在导航栏中显示搜索栏所需的导航项。您不需要创建自己的,尽管您可以在 displaysSearchBarInNavigationBar
设置为 YES(navigationItem)之后通过 searchDisplayController.navigationItem
访问它。是惰性创建的)
当带有搜索显示 Controller 的 View Controller 被请求提供其 navigationItem 时,搜索显示 Controller 将返回其项目(包含搜索栏)而不是 View Controller 的项目。
关于objective-c - iOS7 : how to set navigationItem property of UISearchDisplayController?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/18989032/