1

向下滚动时,UISearchBar 不会随 Tableview 一起移动。

我不想单独放置滚动条。它是一个要求。下面是代码。

customSearchBar = [[UISearchBar alloc] init];
customSearchBar.delegate = self;
[customSearchBar sizeToFit];
objListTable.tableHeaderView = customSearchBar;
4

1 回答 1

1

需要包含一个 View 并在其上添加 UISearchbar,或者提供 Header 视图的高度。默认情况下,它被视为 0.0。

如果你想使用

- (UIView *)tableView:(UITableView *)tableView viewForHeaderInSection:(NSInteger)section

该方法分配一个高度为默认UISeachBar高度的视图。并添加UISearchBar它。

或者UIView在你的代码上添加一个默认UISearchBar高度添加UISearchBar它。它将按您的预期工作。

于 2013-02-05T13:28:04.410 回答