UISearchController searchBar showsCancelButton不被尊重 [英] UISearchController searchBar showsCancelButton not being respected

查看:87
本文介绍了UISearchController searchBar showsCancelButton不被尊重的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我已将UISearchController添加到我的应用程序中,并将其searchBar设置为我的 navigationItem titleView .

I've added a UISearchController to my application and set it's searchBar to the titleView of my navigationItem.

这可行,但是尽管将 showsCancelButton 设置为 false ,我仍然看到取消按钮.

This works but I am seeing the cancel button despite having set showsCancelButton to false.

    searchController = UISearchController(searchResultsController: searchResultsController)
    searchController.searchResultsUpdater = searchResultsUpdater


    // Configure the searchBar
    searchController.searchBar.placeholder = "Find Friends..."
    searchController.searchBar.sizeToFit()
    searchController.searchBar.showsCancelButton = false

    self.definesPresentationContext = true

    navigationItem.titleView = searchController.searchBar

推荐答案

这似乎是iOS中的错误.我描述的相同行为可以在Apple提供的示例项目中看到

This appears to be a bug in iOS. The same behavior I've described can be seen in the example project supplied by Apple

https://developer.apple.com/library/ios/samplecode/TableSearch_UISearchController/Introduction/Intro.html

文档指出,此设置的默认值为 NO ,但事实并非如此.将 showsCancelButton 设置为 NO 似乎无效.

The documentation states that the default for this is NO but this doesn't seem to be the case. Setting showsCancelButton to NO seems to have no effect.

我为此申请了雷达,正在等待回音.

I have filed a radar for this and am waiting to hear back.

这篇关于UISearchController searchBar showsCancelButton不被尊重的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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