【问题标题】:Why do I get a gap between my UISearchBar and my UITableView Cell Header when I touch the UISearchBar on iOS7?当我在 iOS7 上触摸 UISearchBar 时,为什么我的 UISearchBar 和我的 UITableView 单元格标题之间会出现间隙?
【发布时间】:2014-03-08 07:01:25
【问题描述】:

这两张图应该能解释清楚。第一个正常显示我的UITableView。第二个显示当我触摸UISearchBar 并获得焦点时。为什么单元格标题和搜索栏之间有间隙?有谁知道如何解决这个问题?

iOS 7 是这种情况发生的时候。我已经有了这个代码:

- (CGFloat) tableView:(UITableView *)tableView heightForHeaderInSection:(NSInteger)section
{
    if (tableView == self.searchDisplayController.searchResultsTableView)
    {
        return 0;
    }
    else
    {
        return 23;
    }
}

【问题讨论】:

  • 我注意到了同样的问题。你找到解决方案了吗?

标签: ios objective-c xcode cocoa-touch uitableview


【解决方案1】:

我通过删除以下 2 行代码在我的代码中解决了这个问题。

self.viewController.edgesForExtendedLayout = UIRectEdgeNone; self.navigationBar.translucent = NO;

希望能引导你走向正确的方向。

【讨论】:

    【解决方案2】:

    在 iOS 7 中,UITableView 顶部有一小块区域。这是 UITableView 的标题。 将以下代码添加到您的控制器( UITableViewDelegate 类)。

    - (CGFloat) tableView:(UITableView *)tableView heightForHeaderInSection:(NSInteger)section
    {
        return 1;
    }
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2021-08-16
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多