我正在试图添加一个自定义标头到UITableView
,它有一些按钮和一个UISearchBar
。 的问题是,当我尝试使用搜索栏我得到一个消息:将UISearchBar添加到tableView标头中作为子视图
setting the first responder view of the table but we don't know its type (cell/header/footer)
有没有人遇到过这样的问题吗?
我正在试图添加一个自定义标头到UITableView
,它有一些按钮和一个UISearchBar
。 的问题是,当我尝试使用搜索栏我得到一个消息:将UISearchBar添加到tableView标头中作为子视图
setting the first responder view of the table but we don't know its type (cell/header/footer)
有没有人遇到过这样的问题吗?
你通过添加表:
[self.tableView addSubview:customView]
如果是这样,那可能是你的错误。将子视图添加到UITableView需要您明确地将它们添加为页眉,页脚或单元格。尝试:
self.tableView.tableHeaderView = customView
只需按照简单的步骤,在这里..
使用下面的委托方法将其设置为你的表视图的头......
– (UIView *)tableView:(UITableView *)tableView viewForHeaderInSection:(NSInteger)section {
return self.mySearchBar;
}
不正确。您可以以任何您想要的方式将子视图添加到UITableView,就像任何其他UIView一样。 – Anthony 2014-01-09 00:50:03