禁用滑動(dòng)返回手勢(shì)需要在改界面的ViewController中添加如下代碼:
- (void)viewDidAppear:(BOOL)animated
{
[super viewDidAppear:animated];
// 禁用返回手勢(shì)
if ([self.navigationController respondsToSelector:@selector(interactivePopGestureRecognizer)]) {
self.navigationController.interactivePopGestureRecognizer.enabled = NO;
}
}
假設(shè)只有該界面禁用滑動(dòng)返回手勢(shì),還需要添加如下代碼使其他界面能夠繼續(xù)使用滑動(dòng)返回手勢(shì):
- (void)viewWillDisappear:(BOOL)animated
{
[super viewWillDisappear:animated];
// 開啟返回手勢(shì)
if ([self.navigationController respondsToSelector:@selector(interactivePopGestureRecognizer)]) {
self.navigationController.interactivePopGestureRecognizer.enabled = YES;
}
}
最后編輯于 :
?著作權(quán)歸作者所有,轉(zhuǎn)載或內(nèi)容合作請(qǐng)聯(lián)系作者