[英]UISearchBar in UISearchController slips to the right when tapped
I have a UISearchBar inside a UISearchController which pushes to the right when tapped. 我在UISearchController内部有一个UISearchBar,当点击时它会向右推。
This is how the search bar looks after the initial setup 这是初始设置后搜索栏的外观
Below is the code which i use to setup the search bar inside the UIViewController 下面是我用来在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;
Once the user presses on the search bar, it behaves like this. 用户按下搜索栏后,其行为将如下所示。
All of the other controllers are working, fine. 所有其他控制器都正常工作。 It's just one controller which keeps acting in a weird way.
它只是一个控制器,以一种奇怪的方式起作用。
The application supports both iPhone and iPad, the search seems to be working fine on the iPhone but on the iPad it behaves mysteriously. 该应用程序同时支持iPhone和iPad,搜索在iPhone上似乎可以正常运行,但在iPad上却表现得很神秘。
I was able to fix the issue by my self. 我可以自己解决此问题。 What i had to do was:
我要做的是:
self.definesPresentationContext = false;
and to remove it once the view is dismissed 并在视图消失后将其删除
self.searchController.active = false;
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.