【发布时间】:2014-05-08 23:13:27
【问题描述】:
我有这段代码,但方法没有被调用,我该怎么办?我需要委托人吗?
-(void)touchesBegan:(NSSet *)touches withEvent:(UIEvent *)event {
UITouch *touch = [touches anyObject];
if ([touch view] == self.view)
{
}
}
【问题讨论】:
-
那么问题是该方法没有被调用,还是
if语句永远不正确? -
方法没有被调用:(
-
当你触摸一个 UIView 时,UIView 类首先接收到
touchesBegan,如果 UIView 类没有对触摸做任何事情,那么触摸将被转发到 UIViewController 类。但是如果你有一个手势识别器附加到 UIView,那么手势识别器可能会阻止触摸到达 UIViewController。
标签: ios uigesturerecognizer uiresponder