【发布时间】:2011-10-18 13:30:11
【问题描述】:
我正在使用 NSTimer 构建一个旋转横幅来跟踪当前图像,该图像由 5 个不同的图像组成。如果有人点击它,我设置了一个 touchesBegan 来处理横幅上的触摸事件。我的概念验证有效,但将其转移到另一个项目中,它就崩溃了。
-(void)touchesBegan:(NSSet *)touches withEvent:(UIEvent *)event{
UITouch *touch = [[event allTouches] anyObject];
if ([touch view] == myImageView){
[self getImage];
NSLog(@"%@", currentImage);
}
}
现在,当我在项目中设置断点时,它可以很好地抓住触摸,但是当它到达 if ([触摸视图] == myImageView) 它没有检测到图像视图被触摸。
【问题讨论】:
-
我已经重建它并使用它来工作,我忘记了 myImageView.userInteractionEnabled=YES;但是在我们的主要项目中,这不是很好。
标签: iphone ios touch imageview touchesbegan