我有一个UIView
我添加了一个UITapGestureRecognizer
:
UITapGestureRecognizer *tapRecognizer = [[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(tapDetected:)];
tapRecognizer.numberOfTapsRequired=1;
tapRecognizer.numberOfTouchesRequired=1;
[self.myView addGestureRecognizer:tapRecognizer];
然后我在视图中添加一个UIToolBar
带有按钮的:
UIToolbar *topBar = [[UIToolbar alloc ]initWithFrame:CGRectMake(0, 0, self.myView.frame.size.width, 44)];
topBar.barStyle = UIBarStyleBlackTranslucent;
UIBarButtonItem *logout = [[UIBarButtonItem alloc] initWithTitle:@"Logout" style:UIBarButtonItemStyleBordered target:self action:@selector(logout)];
[topBar setItems:@[logout] animated:NO];
我在单击注销按钮时遇到问题,并且我的点击识别器会触发而不是我的注销操作。如果我单击并按住,则会触发注销操作(我猜点击识别器失败了,所以让按钮操作触发)。
按下按钮时如何不触发手势识别器?