繁体   English   中英

轻按时,UISearchController中的UISearchBar向右滑动

[英]UISearchBar in UISearchController slips to the right when tapped

我在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上却表现得很神秘。

我可以自己解决此问题。 我要做的是:

self.definesPresentationContext = false;

并在视图消失后将其删除

self.searchController.active = false;

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM