【问题标题】:Keep uisearchbar in place when user taps search当用户点击搜索时保持 uisearchbar
【发布时间】:2014-06-20 08:45:46
【问题描述】:

我在 tableviewcontroller 中有一个 UISearchBar,如下所示:

self.searchBar = [[UISearchBar alloc] initWithFrame:CGRectMake(0, 0,    self.view.frame.size.width, 44)];
self.tableView.tableHeaderView = self.searchBar;

当用户点击搜索栏进行搜索时,搜索栏会展开以显示取消按钮,但随后还会向下移动约 20 像素,因此搜索栏上方实际上在搜索栏和搜索栏之间有 20 像素的空白区域导航栏。我不明白向下移动的行为以及我能做些什么来防止它。有谁知道究竟是什么原因导致这种情况发生以及我该如何预防?

【问题讨论】:

  • tableView的frame是什么?
  • 你解决了这个问题吗?

标签: ios iphone objective-c ios7 uisearchbar


【解决方案1】:

I was having the same issue,尽管 UISearchController 提供了一个 UISearchBar。对我来说,删除线

self.edgesForExtendedLayout = UIRectEdgeNone;

从演示 VC 的viewDidLoad 方法停止搜索栏下拉。

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2016-10-26
    • 2018-12-01
    • 1970-01-01
    • 1970-01-01
    • 2015-07-05
    • 1970-01-01
    • 2016-10-20
    相关资源
    最近更新 更多