我想弄清楚为什么我使用locationOfTouch:inView时出现错误。最后,我创建了一个只有locationOfTouch调用的新视图,每当触摸视图时我仍然会获得一个SIGABRT。locationOfTouch结果SIGABRT
从import语句除此之外,这里是我认为所有代码:
@interface Dummy : UIView <UIGestureRecognizerDelegate> {
UIPanGestureRecognizer *repositionRecognizer;
}
@end
这里的IMPL:
@implementation Dummy
- (id)initWithFrame:(CGRect)frame
{
self = [super initWithFrame:frame];
if (self) {
repositionRecognizer = [[UIPanGestureRecognizer alloc]
initWithTarget:self
action:@selector(reposition:)];
[repositionRecognizer setDelegate:self];
[self addGestureRecognizer:repositionRecognizer];
self.backgroundColor = [UIColor grayColor];
}
return self;
}
- (void)reposition:(UIGestureRecognizer *) gestureRecognizer {
[gestureRecognizer locationOfTouch:0 inView:self];
//[gestureRecognizer locationInView:self];
}
@end
如果我使用locationInView,它的作品没关系。如果我使用locationOfTouch:inView,只要触摸结束,程序就会中止。
编辑:在控制台上,这个类没有显示错误消息。 IDE使用SIGABRT指向main.m。点击“继续”即会显示“EXC_BAD_INSTRUCTION”。在http://imageshack.us/photo/my-images/849/consolel.png/上可用的屏幕截图
请发布控制台错误消息。 – zaph
控制台是空白的。看到这里:http://imageshack.us/photo/my-images/849/consolel.png/ – undetected
在您的控制台gdb>做一个backtrace或bt看到最后一个崩溃的堆栈。将环境变量NSZombieEnabled设置为YES并调试您的代码。 – 0x8badf00d