点击时,UISearchController中的UISearchBar向右滑动

时间:2016-07-15 19:09:02

标签: ios objective-c ipad uisearchbar

我在UISearchController中有一个UISearchBar,在点击时会向右推。

这是搜索栏在初始设置后的显示方式 Search before tapping

以下是我用来在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;

一旦用户按下搜索栏,其行为就像这样。 After tapping the search bar it pushes to the right

所有其他控制器都正常工作,很好。它只是一个控制器,一直以奇怪的方式行事。

该应用程序支持iPhone和iPad,搜索似乎在iPhone上运行良好,但在iPad上它表现得很神秘。

1 个答案:

答案 0 :(得分:0)

我能够通过自己解决问题。我必须做的是:

self.definesPresentationContext = false;

并在取消视图后将其删除

self.searchController.active = false;