我有这样的UIButton
内部视图:快照 01 http://imageshack.us/a/img827/7240/screenshot20130220at333.png
该按钮绑定到IBAction
:
-(IBAction)deleteButtonPressed :(id)sender{
NSLog(@"DeleteButtonPressed");
}
在这个视图的控制器中,在某些时候我有这个:
UITapGestureRecognizer *tapGesture = [[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(tapAction:)];
tapGesture.numberOfTapsRequired = 1;
tapGesture.numberOfTouchesRequired = 1;
[preview addGestureRecognizer:tapGesture];
还有这个:
- (void)tapAction:(UIGestureRecognizer *)gestureRecognizer{
EditorViewController *vc = [self.storyboard instantiateViewControllerWithIdentifier:@"EditorViewController"];
vc.narration = preview.narration;
self.navigationItem.backBarButtonItem.style = UIBarButtonItemStylePlain;
self.navigationItem.backBarButtonItem.title = @"Done";
vc.navigationItem.backBarButtonItem.style = UIBarButtonItemStylePlain;
vc.navigationItem.backBarButtonItem.title = @"Done";
[self.navigationController pushViewController:vc animated:YES];
}
因此,当我在预览中触摸时,我会加载另一个视图。当我点击按钮时,我的问题就来了。在这种情况下,函数-(IBAction)deleteButtonPressed: (id)sender
不会被执行,但会执行tapAction
。此外,按下时按钮会发生变化。我试图不添加 GestureRecognizer 然后-(IBAction)deleteButtonPressed :(id)sender
被执行。
我做错了什么?当点击按钮时,如何实现这一点,下面的视图不会捕获手势?