iOS 一级界面左滑返回导致app卡顿 黑屏

在一级界面增加一下代码:

 

@property (nonatomic, assign)BOOL isCanUseSideBack;  // 手势是否启动

遵循 UIGestureRecognizerDelegate 协议

 

- (void)viewDidAppear:(BOOL)animated{

    [super viewDidAppear:animated];

    [self cancelSideBack];

}

 

 

- (void)viewDidDisappear:(BOOL)animated {

    [super viewDidDisappear:animated];

    [self startSideBack];

}

 

 

/**

 * 关闭ios右滑返回

 */

-(void)cancelSideBack{

    self.isCanUseSideBack = NO;

    

    if([self.navigationController respondsToSelector:@selector(interactivePopGestureRecognizer)]) {

        self.navigationController.interactivePopGestureRecognizer.delegate = self;

    }

}

/*

 开启ios右滑返回

 */

- (void)startSideBack {

    self.isCanUseSideBack=YES;

    

    if([self.navigationController respondsToSelector:@selector(interactivePopGestureRecognizer)]) {

        self.navigationController.interactivePopGestureRecognizer.delegate = nil;

    }

}

 

- (BOOL)gestureRecognizerShouldBegin:(UIGestureRecognizer*)gestureRecognizer {

    return self.isCanUseSideBack;

}

 

 

 

展开阅读全文

没有更多推荐了,返回首页