我有一个 touchesBegan:
方法,它工作正常。然而,我最近向我的 UIViewController 添加了一个 UIView(一个按钮),现在该按钮没有注册点击,但是我的 touchesBegan:
方法是。
如何让我的 touchesBegan:
方法避开按钮?
这是我当前的 touchesBegan:
方法:
- (void)touchesBegan:(NSSet *)touches withEvent:(UIEvent *)event {
NSLog(@"touches began");
UITouch *touch = [touches anyObject];
switch ([touch tapCount])
{
case 1:
break;
case 2:
if(something)
[doing something];
break;
default:
break;
}
}
最佳答案
确保按钮在前面 ([self.view bringSubviewToFront: myButton]
)。然后你可以询问在 View 中发生的触摸:
if ([touch.view isEqualTo: myButton]) {
NSLog(@"touch was on button");
}
关于iphone - touchesBegan - iPhone 应用程序 UIView,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/6644093/