SWRevealViewController: Remove interaction on frontview when rearview is revealed

前端 未结 15 1257
迷失自我
迷失自我 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条回答
  •  萌比男神i
    2020-12-24 10:42

    I was using the viewWillAppear and viewWillDisappear functions but as I have subviews for almost every item in the side menu I had. My issue was that I had a input field active (keyboard displaying) and accessed the side menu. In the root menu the keyboard hid but after I entered a submenu keyboard showed up again. To solve this I changed the approach to enable and disable the interaction in revealController like this:

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

提交回复
热议问题