【发布时间】:2013-05-15 00:26:07
【问题描述】:
我的观点结构:
UITableView
UITableViewCell
UIScrollView
CustomView
UIButton
问题是当我触摸 UIButton 时它不起作用。 我用代码创建它:
btn = [[UIButton alloc] init];
[btn setImage:image forState:UIControlStateNormal];
[btn addTarget:self action:@selector(tileTouchUpInside) forControlEvents:UIControlEventTouchUpInside];
btn.layer.zPosition = 1;
[self addSubview:btn];
我也添加了这个:
scroll.delaysContentTouches = NO;
scroll.canCancelContentTouches = NO;
但我的按钮无论如何都不起作用。我无法为 UITableView 取消ContentTouches 或设置延迟,因为如果我设置它,UITableView 将停止垂直滚动。
感谢您的帮助!
【问题讨论】:
-
你实现
tileTouchUpInside方法了吗? -
CustomView 的 userInteractionEnabled YES 吗?
-
@Capt.Hook - 谢谢,我试过了,没有帮助。另外,想要添加 - 当我只是将 CustomView 添加到 ViewController 时,没有我们的滚动,它工作得很好。如果放置在滚动视图中,它将停止工作。
-
@Capt.Hook 谢谢,你的链接对我有帮助。
标签: ios uiscrollview uibutton