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

后端 未结 8 1229
情书的邮戳
情书的邮戳 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:17

    There does seem to be a change between iOS6 and iOS7 in that changes to the UI from xxxDidYYY methods sometimes don't work, and you have to do it in the xxxWillYYY method or in some code executed from the main event loop (e.g. in a block or after a short delay).

    In your case, try this:

    - (BOOL)searchBarShouldBeginEditing:(UISearchBar *)searchBar
    {
        searchBar.showsCancelButton = YES;
        return YES;
    }
    

提交回复
热议问题