SWRevealViewController: Remove interaction on frontview when rearview is revealed

前端 未结 15 1334
迷失自我
迷失自我 2020-12-24 10:05

I need to disable user interaction on front view when rear view is revealed. Found some others asking the same thing but can\'t really understand where or how to implement t

15条回答
  •  北荒
    北荒 (楼主)
    2020-12-24 10:43

    I have used another approach to achieve the same outcome not sure if it helps.

    Assign SWRevealViewControllerDelegate to AppDelegate

    - (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
    {
        SWRevealViewController* reveal = (SWRevealViewController*)self.window.rootViewController;
        reveal.delegate = self;
    
        // other bootstrapping code
    }
    

    and then in the delegate method -(void)revealController:(SWRevealViewController *)revealController willMoveToPosition:(FrontViewPosition)position as below:

    -(void)revealController:(SWRevealViewController *)revealController willMoveToPosition:(FrontViewPosition)position
    {
        if(position == FrontViewPositionLeft){
            [revealController.frontViewController.view setUserInteractionEnabled:YES];
            [revealController.frontViewController.revealViewController tapGestureRecognizer];
        }else{
            [revealController.frontViewController.view setUserInteractionEnabled:NO];
        }
    }
    

    UPDATED: added this line [revealController.frontViewController.revealViewController tapGestureRecognizer] to close the revealed controller when tap on frontviewcontroller

提交回复
热议问题