我有几个 IBAction 附加到 UIButtons。IBActions 工作正常,直到我添加以下代码:
- (void)viewDidLoad {
[super viewDidLoad];
NSLog(@"View Did Load");
[self addGestureRecognizersToView:drawImage];
}
在我添加那段代码后,IBActions 不会触发。当我触摸 UIButtons 时,它们会突出显示,但没有任何 IBAction 代码被命中。
这是我的 addGestureRecognizers 代码:
- (void)addGestureRecognizersToView:(UIImageView *)theView {
UIPanGestureRecognizer *panGesture = [[UIPanGestureRecognizer alloc] initWithTarget:self action:@selector(handlePan:)];
[panGesture setMaximumNumberOfTouches:2];
[panGesture setMinimumNumberOfTouches:1];
//panGesture.delegate = drawImage;
[theView addGestureRecognizer:panGesture];
[panGesture release];
UITapGestureRecognizer *doubleFingerTap = [[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(handleDoubleTap:)];
[doubleFingerTap setNumberOfTapsRequired:2];
[self.view addGestureRecognizer:doubleFingerTap];
[doubleFingerTap release];
UITapGestureRecognizer *singleFingerTap = [[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(handleSingleTap:)];
[singleFingerTap setNumberOfTapsRequired:1];
[self.view addGestureRecognizer:singleFingerTap];
[singleFingerTap release];
}
如果我注释掉 singleFingerTap 代码,它就可以工作。我猜我不应该使用 alloc,因为我之前已经在 doubleFingerTap 中分配过一次?
关于我可能在这里遗漏的任何想法?