TouchesBegan 仅在特定的 UIView 中开始
我有三个 UIView 实例:
UIView *view1;
UIView *view2;
UIView *view3;
-(void)touchesBegan:(NSSet *)touches withEvent:(UIEvent *)event {
UITouch *touch =[touches anyObject];
CGPoint startPoint =[touch locationInView:self.view];
}
但我希望 toch-action 只出现在 view2 中。如果我制作: locationInView:view2 则不起作用,
-(void)touchesBegan:(NSSet *)touches withEvent:(UIEvent *)event {
UITouch *touch =[touches anyObject];
CGPoint startPoint =[touch locationInView:view2];
}
我做错了什么?我如何检查哪个视图是我在 iPhone 上实际可以看到的视图?
I have three UIView
instances:
UIView *view1;
UIView *view2;
UIView *view3;
-(void)touchesBegan:(NSSet *)touches withEvent:(UIEvent *)event {
UITouch *touch =[touches anyObject];
CGPoint startPoint =[touch locationInView:self.view];
}
But i want that the toch-action only go in view2. It doesnt work if i make: locationInView:view2
-(void)touchesBegan:(NSSet *)touches withEvent:(UIEvent *)event {
UITouch *touch =[touches anyObject];
CGPoint startPoint =[touch locationInView:view2];
}
What do I wrong? How can i check, which view is the view i actually can see on my iphone?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
在您不希望处理触摸的视图中将 userInteractionEnabled 设置为 false。
set userInteractionEnabled to false in the view in which you don't want your touch to be handled.