我想禁用整个视图的用户交互,但也允许在视图上点按手势。假设主视图上方有一个菜单,并且如果用户再次点击主视图,则后菜单消失。但是,只要显示菜单,则应禁用与主视图的所有其他交互。 这里是我尝试做的是: 我定义的tapGestureRecognizer这样的:禁用用户交互但在UIViewController中允许点按手势
@interface GroupMasterViewController() <SWRevealViewControllerDelegate>
@property NSMutableArray *groups;
@property (nonatomic, strong) UITapGestureRecognizer *tapGestureRecognizer;
@end
在我viewDidLoad方法我有这样的:
self.tapGestureRecognizer = [[UITapGestureRecognizer alloc] initWithTarget:self.revealViewController action:@selector(rightRevealToggle:)];
[self.view addGestureRecognizer:self.tapGestureRecognizer];
self.tapGestureRecognizer.enabled = NO;
而且在委托方法,被解雇时,菜单打开或关闭:
- (void)revealController:(SWRevealViewController *)revealController willMoveToPosition:(FrontViewPosition)position
{
if (position == FrontViewPositionLeftSide) {
self.tapGestureRecognizer.enabled = YES;
self.view.userInteractionEnabled = NO;
self.tabBarController.tabBar.userInteractionEnabled = NO;
}
else if (position == FrontViewPositionLeft){
self.tapGestureRecognizer.enabled = NO;
self.view.userInteractionEnabled = YES;
self.tabBarController.tabBar.userInteractionEnabled = YES;
}
}
问题是,tapGestureRecognizer不再工作了,如果我禁用用户交互。
非常感谢您的帮助。
要禁用整个视图,以便UITapGestureRecognizer不会work.Please使意见的主视图的子视图,并启用和禁用你想 – Rose