iOS 7 doesn't show cancel button of search bar in navigation bar

后端 未结 8 1220
情书的邮戳
情书的邮戳 2021-02-04 02:47

In an app that\'s supposed to run on iOS 6 and iOS 7, the cancel button of the search bar embedded in the navigation bar is not shown anymore if the app is run on iOS 7. On iOS

8条回答
  •  清酒与你
    2021-02-04 03:18

    If you are using your UISearchBar with an UISearchDisplayController, you can simply set the cancel button to show, in the "searchDisplayControllerWillBeginSearch" delegate method, like so: (iOS 7 tested)

    -(void)searchDisplayControllerWillBeginSearch:(UISearchDisplayController *)controller{
        controller.searchBar.showsCancelButton = YES;
    }
    

提交回复
热议问题