touchesBegan没有被触发

时间:2012-05-04 01:26:17

标签: iphone

我使用下面的代码来检测物体上的触摸

- (void)touchesBegan:(NSSet *)touches withEvent:(UIEvent *)event {
    NSArray *allTouches = [touches allObjects];

    for (UITouch *touch in allTouches)
    {
           NSLog(@"TOUCH DETECT");

    }
}

但未触发

欢迎任何评论

1 个答案:

答案 0 :(得分:5)

什么样的物体?只为UIResponder子类调用touchesBegan:withEvent:

此外,如果是UIView,请确保userInteractionEnabled为YES。

相关问题