TouchesBegan只在特定的UIView中

时间:2010-10-15 19:31:52

标签: uiview location touchesbegan

我有三个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上可以看到的视图?

1 个答案:

答案 0 :(得分:1)

在您不希望处理触控的视图中将userInteractionEnabled设置为false。