swift返回首页底部留白

 

 

 
进入二级界面,返回到 BaseTabBarController 的任意一级界面,在部分机型会出现一下情况
 
出现的代码
weakSelf.navigationController?.popToRootViewController(animated: false)
guard let tabBarC = UIApplication.shared.keyWindow?.rootViewController as? BaseTabBarController else {
return
}
tabBarC.tabBar.isHidden = false
if tabBarC.selectedIndex != UITabBarController.SelectType.resume.rawValue {
tabBarC.selectedIndex = UITabBarController.SelectType.resume.rawValue
}
 
 
解决
 
BaseTabBarController.back(.resume)
 
分析
 
可能和 viewController.hidesBottomBarWhenPushed = true 使用不规范;
还有在调用popToRootViewController 后立即调用了 tabBarC.tabBar.isHidden = false 的有关
 
 
 

extension BaseTabBarController{

    

    /// 回到首页

    static func back(_ type: UITabBarController.SelectType = .recruit) {

        /// 直接 backroot 在12上view的高度会少49、故用此方式替换;

        let nav = GetCurrentVC()?.navigationController

        let vcs = nav?.viewControllers ?? []

        if vcs.count > 1 {

            nav?.setViewControllers([vcs[0]], animated: false)

        }

        guard let tabBarCrl = UIApplication.shared.keyWindow?.rootViewController as? UITabBarController else { return }

        tabBarCrl.selectedIndex = type.rawValue

    }

    

}

posted @   super1250  阅读(94)  评论(0编辑  收藏  举报
相关博文:
阅读排行:
· 震惊!C++程序真的从main开始吗?99%的程序员都答错了
· 【硬核科普】Trae如何「偷看」你的代码?零基础破解AI编程运行原理
· 单元测试从入门到精通
· 上周热点回顾(3.3-3.9)
· winform 绘制太阳,地球,月球 运作规律
历史上的今天:
2016-03-18 xmpp笔记2(客户端到服务器的例子)--xml
点击右上角即可分享
微信分享提示