ysn*_*nky 9 iphone scroll uibutton uiscrollview
我有水平UIScrollView,从水平延伸UIScrollView,我UIButtons水平添加.我只能滚动按钮区域,但如果我想滚动任何按钮是火灾UIControlEventTouchUpInside事件.我不想要这个.我想火UIControlEventTouchUpInside行动,如果我点击我要滚动,如果我滚动.
那么如何将滚动事件传递UIButton给UIScrollView?
如果您继承 NSButton 并制作该类型的按钮并覆盖子类中的以下内容,您可以将事件传递回父视图,在您的情况下为滚动视图
以下将使按钮永远不会触发事件,而所有事件都将由父视图处理:
- (void)touchesBegan: (NSSet *)touches withEvent:(UIEvent *)event {
[self.nextResponder touchesBegan:touches withEvent:event];
}
- (void)touchesMoved: (NSSet *)touches withEvent:(UIEvent *)event {
[self.nextResponder touchesMoved:touches withEvent:event];
}
- (void)touchesEnded:(NSSet *)touches withEvent:(UIEvent*)event
{
[self.nextResponder touchesEnded:touches withEvent:event];
}
Run Code Online (Sandbox Code Playgroud)
如果您想让按钮处理这些事件之一,请使用
[super touchesEnded:touches withEvent:event];
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
3605 次 |
| 最近记录: |