Open arr0813 opened 6 years ago
简书地址: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里面。。。完美解决!!!
简书地址:https://www.jianshu.com/p/9769337d297f
解决方法是用的@icetime17的,只是代码放的位置不太一样,他的RootViewController是继承自RESideMenu的,而我是自己写了个RESideMenu的分类进行设置的。
关键代码就👇几句:
-(void)viewWillAppear:(BOOL)animated
{
}
-(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里面。。。完美解决!!!