Swift3.0手势侧滑BUG

  • 出现三个小蓝点
  • 在navigationViewController 的rootViewController中使用侧滑手势后,push,出现卡顿现象。按下home键,在进入就会跳转到push的界面。
class BaseNavigationVC: UINavigationController,UINavigationControllerDelegate{
    var popGestureDelegate: UIGestureRecognizerDelegate?
    
    override func viewDidLoad() {
        super.viewDidLoad()
        self.popGestureDelegate = self.interactivePopGestureRecognizer?.delegate
        self.delegate = self
   
    }
    
    //MARK: - push事件拦截
    override func pushViewController(_ viewController: UIViewController, animated: Bool) {
        //  去除手势蓝点
        viewController.navigationItem.backBarButtonItem = UIBarButtonItem(title: "", style: .done, target: nil, action: nil)
        if childViewControllers.count > 0 {
            viewController.hidesBottomBarWhenPushed = true
        }
        super.pushViewController(viewController, animated: animated)
    }
    
   //MARK: - 导航栏试图完全显示
    func navigationController(_ navigationController: UINavigationController, didShow viewController: UIViewController, animated: Bool) {
    
        if viewController == self.viewControllers[0] { //rootVC禁止侧滑
            self.interactivePopGestureRecognizer!.delegate = self.popGestureDelegate
        }
        else {    //清空滑动返回手势的代理就能实现滑动返回功能
            self.interactivePopGestureRecognizer!.delegate = nil
        }
    }

    
}
最后编辑于
©著作权归作者所有,转载或内容合作请联系作者
平台声明:文章内容(如有图片或视频亦包括在内)由作者上传并发布,文章内容仅代表作者本人观点,简书系信息发布平台,仅提供信息存储服务。

推荐阅读更多精彩内容

  • Android 自定义View的各种姿势1 Activity的显示之ViewRootImpl详解 Activity...
    passiontim阅读 174,143评论 25 709
  • 发现 关注 消息 iOS 第三方库、插件、知名博客总结 作者大灰狼的小绵羊哥哥关注 2017.06.26 09:4...
    肇东周阅读 12,273评论 4 61
  • 2017年6月22日 星期四 天气阴 崔笑妈妈亲子日记 这两天不在家,女儿每天都要打两个电话给我,问问...
    崔笑妈妈阅读 270评论 3 3
  • 睁一只眼闭一只眼,梦想好似打了个盹而已! 岁月更迭,儿时的梦想早已破灭。昔日的那个少年也早已长大,明白了现实就在脚...
    Guang大人阅读 255评论 2 5
  • 美美的一餐
    点滴524阅读 247评论 0 0