IOS8 UISearchController直接显示搜索栏

IOS8 UISearchController直接显示搜索栏,第1张

概述我正在尝试使用UISearchController为我的 iphone应用程序显示一个简单的搜索屏幕. 我使用了UITableViewController和UISearchController,它嵌入在UINavigationController中 >这让我看到以下屏幕(状态1) >当用户点击搜索字段时,我会看到下面的屏幕(状态2): 搜索栏很好地显示在状态栏下方的屏幕顶部. 我想做的是直接获得状 我正在尝试使用UISearchController为我的 iphone应用程序显示一个简单的搜索屏幕.
我使用了UItableVIEwController和UISearchController,它嵌入在UINavigationController中

>这让我看到以下屏幕(状态1)

>当用户点击搜索字段时,我会看到下面的屏幕(状态2):
搜索栏很好地显示在状态栏下方的屏幕顶部.

我想做的是直接获得状态2而不进入状态1

我试图添加此代码

presentVIEwController(searchController,animated: true,completion: nil)

但它要么不显示搜索栏,如果动画是假的,或者显示它我想要但是在不必要的过渡后暂时显示导航栏

解决方法 好的,我刚刚发现如何阅读这个答案 UISearchController in a UIViewController

我只需要像这样添加搜索栏以获得所需的效果

searchController.hIDesNavigationbarDuringPresentation = false    // tableVIEw.tableheaderVIEw = searchController.searchbar    navigationItem.TitleVIEw = searchController.searchbar
总结

以上是内存溢出为你收集整理的IOS8 UISearchController直接显示搜索栏全部内容,希望文章能够帮你解决IOS8 UISearchController直接显示搜索栏所遇到的程序开发问题。

如果觉得内存溢出网站内容还不错,欢迎将内存溢出网站推荐给程序员好友。

欢迎分享,转载请注明来源:内存溢出

原文地址:https://54852.com/web/1012474.html

(0)
打赏 微信扫一扫微信扫一扫 支付宝扫一扫支付宝扫一扫
上一篇 2022-05-22
下一篇2022-05-22

发表评论

登录后才能评论

评论列表(0条)

    保存