【问题标题】:UISearchBar in UISearchController slips to the right when tappedUISearchController 中的 UISearchBar 在点击时滑到右侧
【发布时间】:2016-11-19 02:24:54
【问题描述】:

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

【问题讨论】:

    标签: ios objective-c ipad uisearchbar


    【解决方案1】:

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

    self.definesPresentationContext = false;
    

    并在视图关闭后将其删除

    self.searchController.active = false;
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2018-09-27
      • 1970-01-01
      • 2021-11-23
      • 1970-01-01
      • 1970-01-01
      • 2021-07-19
      • 2019-12-28
      相关资源
      最近更新 更多