ビュー全体でのユーザー操作を無効にしたいのですが、ビューでのタップ ジェスチャも許可します。メイン ビューの上にメニューがあり、ユーザーがメイン ビューをもう一度タップすると、背面のメニューが消えるとします。ただし、メニューが表示されている限り、メイン ビューとの他のすべての対話は無効にする必要があります。これが私がそれをやろうとする方法です: 私は次のように tapGestureRecognizer を定義しました:
@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 が機能しなくなることです。
よろしくお願いします。