1.需要添加手势的界面
(1)addBackGesture()
(2) 设置手势返回代理
// MARK: - 添加返回手势
extension JYRTSShopDetialConteoller:UIGestureRecognizerDelegate{
func addBackGesture(){
self.navigationController?.interactivePopGestureRecognizer?.delegate = self
self.navigationController?.interactivePopGestureRecognizer?.isEnabled = true
}
}
2.
前提是 本界面导航控制器是隐藏的
(1) 在home控制器设置 代理
self.navigationController?.delegate = self
(2)在代理方法隐藏 导航控制器
func navigationController(_ navigationController: UINavigationController, willShow viewController: UIViewController, animated: Bool) {
if viewController is JYRTSShopDetialConteoller{
self.navigationController?.setNavigationBarHidden(true, animated: true)
}
}