簡體   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