触摸 UITableView 的背景视图上的按钮?
我在 UITableView
的 backgroundview
底部放置了一些按钮,并设置了一个透明的 tableFooterView
,其高度在滚动表格时显示按钮到底部。效果如下所示。
但按钮无法单击。我尝试过覆盖
-(void)touchesBegan:(NSSet *)touches withEvent:(UIEvent *)event
{
[self.backgroundview touchesBegan:touches withEvent:event];
[super touchesBegan:touches withEvent:event];
}
tableView 类,当单击按钮时,会引发错误。
Google 表示 tableview 的触摸事件处理非常复杂 TvT。
I have put some buttons on the bottom of backgroundview
of a UITableView
, and set a transparent tableFooterView
with a height to show the buttons when scroll table to the bottom. The effect is something showing below.
But the buttons are unable to click. I've tried overiding
-(void)touchesBegan:(NSSet *)touches withEvent:(UIEvent *)event
{
[self.backgroundview touchesBegan:touches withEvent:event];
[super touchesBegan:touches withEvent:event];
}
of the tableView class, when click the buttons, error raise.
Google says the touch event handling of tableview is very complex TvT.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
这是一个糟糕的设计理念。
a) 整个 UITableView 对触摸做出反应。让部分区域将触摸传递给子视图很容易出错。
b) 如果您的表格只有几个单元格,会发生什么情况?
更好的方法:
将表格中的最后一个单元格设置为底部菜单。或者将页脚视图作为菜单。
它总是显示为最后一个元素,并且总是对触摸做出反应。
This is a bad design concept.
a) entire UITableView reacts to touches. Making partial areas pass touches to the subview is prone to errors.
b) what will happen if your table only have few cells?
The better approach:
Make the last cell in the table to be your bottom menu. Or the footer view to be the menu.
It will always show up as the last element and it will always react to the touches.