【发布时间】:2013-11-16 18:29:30
【问题描述】:
在开发演示应用时,我在 XCode 中添加了一些手势,它们运行良好。但是,在代码中添加手势会在运行时给出 NSInvalidArgumentException,此时应该调用手势。我试图将此手势添加到 ImageView,但后来我也尝试使用 self.view。一切都无济于事:(
这可能是一些与内存相关的问题,但我无法解决它。任何帮助将不胜感激。
附:为 imageView 启用了用户交互 - 当在 XCode 中添加手势时,代码运行良好。
这是调试器显示的内容:
'NSInvalidArgumentException',原因:'-[UIView handleToyImageTap:]:无法识别的选择器发送到实例。
代码如下:
- (void)viewDidLoad
{
[super viewDidLoad];
// Do any additional setup after loading the view, typically from a nib.
previousRotation = 4.0;
[self.toyImageTappable addGestureRecognizer: [[UITapGestureRecognizer alloc] initWithTarget:self.toyImageTappable action:@selector(handleToyImageTap:)]];
}
- (void) handleToyImageTap:(UITapGestureRecognizer *)sender {
//Rotate image by 45 degree
self.toyImageTappable.transform = CGAffineTransformMakeRotation(M_PI/previousRotation);
previousRotation = previousRotation + 4.0;
if (previousRotation == 16.0)
previousRotation = 4.0;
}
【问题讨论】:
标签: ios objective-c ios7 gesture-recognition runtimeexception