我有一个UISearchBar在一个UISearchController里面,当点击它的时候,它会向右推。
--这是搜索栏处理初始设置的方式

下面是我用来在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上却神秘地运行。
发布于 2016-07-15 20:13:30
我自己解决了这个问题。我要做的是:
self.definesPresentationContext = false;一旦这个观点被驳回,就删除它
self.searchController.active = false;https://stackoverflow.com/questions/38403507
复制相似问题