zoukankan      html  css  js  c++  java
  • swift

    1. viewdidload 设置代理

    self.navigationController?.delegate = self
    

      

    2.代理里面指定VC 隐藏

    //MARK: - 导航栏delegate
    extension JYHomeViewController:UINavigationControllerDelegate {
    
        /// 此方法会在controller的viewWillApper方法调用后开始调用(使用时注意controller的生命周期)
        func navigationController(_ navigationController: UINavigationController, willShow viewController: UIViewController, animated: Bool) {
            if viewController is JYHomeViewController || viewController is JYPhotoBrowserController || viewController is JYRTSRootViewController {
                JY_WINDOW?.removeBubbleView()
                self.navigationController?.setNavigationBarHidden(true, animated: true)
            }else{
                self.navigationController?.setNavigationBarHidden(false, animated: true)
            }
        }
    }
    

      
    3. 在根控制器首页 禁用手势, 不管有几个 homeVc, 有俩tabbar 就在俩homeVc都写上

    extension JYHomeViewController: UIGestureRecognizerDelegate {
        /// 禁止使用手势返回
        func forbidhenSideBack() {
            self.isCanSideBack = false
            if (self.navigationController?.responds(to:#selector(getter: self.navigationController?.interactivePopGestureRecognizer))) == true {
                self.navigationController?.interactivePopGestureRecognizer?.delegate = self
            }
        }
        /// 恢复手势返回
        func resetSideBack() {
            self.isCanSideBack = true
            if (self.navigationController?.responds(to:#selector(getter: self.navigationController?.interactivePopGestureRecognizer))) == true {
                self.navigationController?.interactivePopGestureRecognizer?.delegate = nil
            }
        }
        func gestureRecognizerShouldBegin(_ gestureRecognizer: UIGestureRecognizer) -> Bool {
            return self.isCanSideBack
        }
    }
    

      在 willappear 和willDisaapper 使用

        override func viewWillAppear(_ animated: Bool) {
            super.viewWillAppear(animated)
            self.forbidhenSideBack()
        }
        override func viewWillDisappear(_ animated: Bool) {
            super.viewWillDisappear(animated)
            self.resetSideBack()
        }
    

      

  • 相关阅读:
    Package manager has died异常PackageInfo 引发 Crash
    Android Bitmap变迁与原理解析(4.x-8.x)
    Rxjava2不能再发射Null了
    [转]C语言的int最值问题,以及原码反码及补码
    自定义gradle插件
    ReentrantLock(重入锁)的使用
    HashSet、TreeSet和LinkedHashSet分别基于HashMap、TreeMap和LinkedHashMap
    Java类加载双亲委托模式优点
    为什么HTTPS比HTTP安全,以及两者的优缺点
    android4.4之后的HttpUrlConnection的实现是基于okhttp
  • 原文地址:https://www.cnblogs.com/qingzZ/p/9983673.html
Copyright © 2011-2022 走看看