自定义leftBarButtonItem 右滑返回

#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;

}

最后编辑于
©著作权归作者所有,转载或内容合作请联系作者
平台声明:文章内容(如有图片或视频亦包括在内)由作者上传并发布,文章内容仅代表作者本人观点,简书系信息发布平台,仅提供信息存储服务。

推荐阅读更多精彩内容

  • 前言:ios7开始 苹果增加了页面 右滑返回的效果;具体的是以UINavigationController为容器的...
    iPhone阅读 3,780评论 2 3
  • ios7开始 苹果增加了页面 右滑返回的效果;具体的是以UINavigationController为容器的Vie...
    Q6尐漒阅读 1,334评论 0 0
  • 使用系统的方案 创建BaseNavgationViewController 继承父类UINavigationCon...
    曾经那样美阅读 2,738评论 0 1
  • 首先iOS7以后系统默认自带了侧滑功能,当用户在界面的左边滑动的时候,就会有侧滑功能。 但是如果我们从从导航控制器...
    稻草人12138阅读 12,239评论 0 3
  • 1、禁止手机睡眠[UIApplication sharedApplication].idleTimerDisabl...
    DingGa阅读 1,152评论 1 6