iOS-某個頁面禁止側滑手勢返回


1.在視圖已經出現時設置:

- (void)viewDidAppear:(BOOL)animated
{
    [super viewDidAppear:animated];
    //隱藏返回按鈕
    self.navigationItem.hidesBackButton = YES;
    //禁止頁面左側滑動返回,注意,如果僅僅需要禁止此單個頁面返回,還需要在viewWillDisapper下開放側滑權限
    // 禁用返回手勢
    if ([self.navigationController respondsToSelector:@selector(interactivePopGestureRecognizer)]) {
        self.navigationController.interactivePopGestureRecognizer.enabled = NO;
    }
}

2.在視圖已經消失時設置:

- (void)viewDidDisappear:(BOOL)animated {
    [super viewDidDisappear:animated];
    // 開啟返回手勢
    if ([self.navigationController respondsToSelector:@selector(interactivePopGestureRecognizer)]) {
        self.navigationController.interactivePopGestureRecognizer.enabled = YES;
    }
}

 


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM