美文网首页
自定义leftBarButtonItem 右滑返回

自定义leftBarButtonItem 右滑返回

作者: iOS_大菜鸟 | 来源:发表于2017-09-12 17:22 被阅读0次

#import

@interfaceBaseNavigationController :UINavigationController

@property(nonatomic,weak)UIViewController* currentShowVC;

@end

@implementation BaseNavigationController

-(id)initWithRootViewController:(UIViewController*)rootViewController

{

BaseNavigationController* nvc = [superinitWithRootViewController:rootViewController];

self.interactivePopGestureRecognizer.delegate=self;

nvc.delegate=self;

returnnvc;

}

-(void)navigationController:(UINavigationController*)navigationController willShowViewController:(UIViewController*)viewController animated:(BOOL)animated

{

}

-(void)navigationController:(UINavigationController*)navigationController didShowViewController:(UIViewController*)viewController animated:(BOOL)animated

{

if(navigationController.viewControllers.count==1)

self.currentShowVC=Nil;

else

self.currentShowVC= viewController;

}

-(BOOL)gestureRecognizerShouldBegin:(UIGestureRecognizer*)gestureRecognizer

{

if(gestureRecognizer ==self.interactivePopGestureRecognizer) {

return(self.currentShowVC==self.topViewController);

}

returnYES;

}

相关文章

网友评论

      本文标题:自定义leftBarButtonItem 右滑返回

      本文链接:https://www.haomeiwen.com/subject/mvocsxtx.html