我在UISearchController中有一个UISearchBar,在点击时会向右推。
以下是我用来在UIViewController中设置搜索栏的代码
//Set self object to recieve all the updates of UISearchResultsController
self.searchResultsUpdater = self;
//Hide navigation bar during presentation of the UISearchController.
self.hidesNavigationBarDuringPresentation = YES;
//set delegates to UISearchBar and UISearchController
self.delegate = self;
self.searchBar.delegate = self;
//Set scope bars that does not exist
self.searchBar.scopeButtonTitles = [NSArray array];
//Some additional settings that can be configured
self.context.definesPresentationContext = YES;
self.dimsBackgroundDuringPresentation = NO;
[self.searchBar sizeToFit];
self.tableView.tableHeaderView = self.searchBar;
self.context.edgesForExtendedLayout = UIRectEdgeTop;
self.searchBar.clipsToBounds = YES;
所有其他控制器都正常工作,很好。它只是一个控制器,一直以奇怪的方式行事。
该应用程序支持iPhone和iPad,搜索似乎在iPhone上运行良好,但在iPad上它表现得很神秘。
答案 0 :(得分:0)
我能够通过自己解决问题。我必须做的是:
self.definesPresentationContext = false;
并在取消视图后将其删除
self.searchController.active = false;