最近做公司项目遇到个bug 、在tableview的backgroundview上加了个view 缺发现view上的button在ios7上没响应、对只有ios7 其他上面正常的。
代码是这样的
self.tableView.backgroundView = self.emptyView;
然后解决问题的代码是这样的
[self.tableView addSubview:self.emptyView];
那就来研究下这个backgroundview吧。
文档是这样说的:
the background view will be automatically resized to track the size of the table view. this will be placed as a subview of the table view behind all cells and headers/footers. default may be non-nil for some devices.
也就是说多了一个view在tableview上面。
在iOS开发中,遇到一个bug:为UITableView设置的backgroundView中的按钮在iOS7上无法响应点击。问题出在使用`self.tableView.backgroundView = self.emptyView;`,而解决方案是将背景视图直接添加为子视图:`[self.tableView addSubview:self.emptyView];`。这涉及到UITableView的backgroundView特性,它会自动调整大小,并置于所有单元格和头/尾视图后面。
2122

被折叠的 条评论
为什么被折叠?



