iOS 9 searchBar disappears from table header view when UISearchController is active

后端 未结 13 1308
無奈伤痛
無奈伤痛 2020-12-07 20:37

The structure:

View1 (click a button) -> present modally (MyModalView: UITableViewController)

MyModalView has UISearchController embedded. The searchBar of U

13条回答
  •  南笙
    南笙 (楼主)
    2020-12-07 21:16

    Thanks @wiles duan and @Techprimate

    In my case, I fixed this issue by setting:

    self.definesPresentationContext = NO;
    

    And implement the following 2 methods in UISearchControllerDelegate

    - (void)willPresentSearchController:(UISearchController *)searchController {
        // do something before the search controller is presented
        self.navigationController.navigationBar.translucent = YES;
    }
    
    -(void)willDismissSearchController:(UISearchController *)searchController
    {
        self.navigationController.navigationBar.translucent = NO;
    }
    

提交回复
热议问题