Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

完美解决RESideMenu二级界面能侧滑的bug(即在二级页面关闭侧滑菜单功能) #312

Open
arr0813 opened this issue May 7, 2018 · 0 comments

Comments

@arr0813
Copy link

arr0813 commented May 7, 2018

简书地址:https://www.jianshu.com/p/9769337d297f

解决方法是用的@icetime17的,只是代码放的位置不太一样,他的RootViewController是继承自RESideMenu的,而我是自己写了个RESideMenu的分类进行设置的。

关键代码就👇几句:

-(void)viewWillAppear:(BOOL)animated

{

[super viewWillAppear:animated];

[[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(disableRESideMenu) name:@"disableRESideMenu" object:nil];

[[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(enableRESideMenu) name:@"enableRESideMenu" object:nil];

}

-(void)enableRESideMenu

{ self.panGestureEnabled = YES;}

-(void)disableRESideMenu

{ self.panGestureEnabled = NO;}

分类设置完后,在需要关闭侧滑菜单的界面执行👇

[[NSNotificationCenter defaultCenter] postNotificationName:@"disableRESideMenu" object:nil];

为什么我要把代码放在viewWillAppear里呢?

尝试放在viewDidLoad里面,但是程序运行起来黑屏;

尝试放在+(void)load方法里面,但是崩在发送通知的方法,提示找不到disableRESideMenu方法,为什么呢?因为+(void)load是类方法,不能在里面直接使用对象方法- (void)enableRESideMenu。

因此,我尝试了一下放在viewWillAppear里面。。。完美解决!!!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant