UISearchController searchBar showsCancelButton not being respected

后端 未结 12 2319
北荒
北荒 2021-02-13 03:58

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

This works but I am seeing t

12条回答
  •  甜味超标
    2021-02-13 04:15

    It may be helpful to note that this has changed on iOS 13 and quote Apple's documentation on showsCancelButton, currently only available on UISearchBar.h and not on developer.apple.com

    /* New behavior on iOS 13.
     If the search bar is owned by a UISearchController, then using the setter
     for this property (as well as -setShowsCancelButton:animated:) will implicitly
     set the UISearchController's automaticallyShowsCancelButton property to NO.
     */
    

    automaticallyShowsCancelButton has been introduced on iOS 13.0 and should clarify what @pbasdf had already pointed out in his answer: that the buggy behavior is something intrinsic to UISearchController.

提交回复
热议问题