系統(tǒng)側(cè)滑必須從左側(cè)屏幕邊緣開始滑動,很不方便。所以使用手勢替代系統(tǒng)側(cè)滑。
遵循手勢delegate
UIGestureRecognizerDelegate
// 禁用系統(tǒng)自帶側(cè)滑
self.navigationController.interactivePopGestureRecognizer.enabled = NO;
// 獲取系統(tǒng)自帶滑動手勢的target對象
id target = self.navigationController.interactivePopGestureRecognizer.delegate;
// 創(chuàng)建全屏滑動手勢,調(diào)用系統(tǒng)自帶滑動手勢的target的action方法
UIPanGestureRecognizer *pan = [[UIPanGestureRecognizer alloc] initWithTarget:target action:@selector(handleNavigationTransition:)];
// 設(shè)置手勢代理,攔截手勢觸發(fā)
pan.delegate = self;
// 給導(dǎo)航控制器的view添加全屏滑動手勢
[self.view addGestureRecognizer:pan];
- (void)handleNavigationTransition:(UIPanGestureRecognizer*)sender{
[self.navigationController popViewControllerAnimated:1];
}