【问题标题】:hide tab bar in splash screen in swift 5在swift 5中隐藏启动画面中的标签栏
【发布时间】:2020-07-29 05:46:17
【问题描述】:

我已经在 iOS 应用程序中实现了启动画面。它有 2-3 秒的持续时间,但我的主屏幕上的 tabarcontroller 显示在初始屏幕中。enter image description here

【问题讨论】:

  • 你能再显示一些代码吗?您是如何添加标签栏的?在哪里添加?
  • splash 已经没有标签栏 .. 这取决于你的代码如何延迟你的 splash

标签: ios swift iphone mobile swift5


【解决方案1】:

一种方法是在 AppDelegate 中为您的初始屏幕添加一个单独的窗口。这样您就可以将标签栏控制器保留为您的根视图控制器。

@UIApplicationMain
class AppDelegate: UIResponder, UIApplicationDelegate {
    var window: UIWindow?
    let launchView = UIStoryboard(name: "LaunchScreen", bundle: nil).instantiateInitialViewController()?.view ?? UIView()

    func application(_ application: UIApplication, didFinishLaunchingWithOptions 
        launchOptions: [UIApplication.LaunchOptionsKey: Any]?) -> Bool {
        launchView.frame = window?.frame ?? .zero
        window?.addSubview(launchView)

        DispatchQueue.main.asyncAfter(deadline: .now() + 5) {
            // splash screen shows for 5 seconds
            launchView.removeFromSuperview()
        }

        return true
    }
}

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2021-05-30
    • 1970-01-01
    • 1970-01-01
    • 2016-05-18
    • 2014-01-22
    • 1970-01-01
    相关资源
    最近更新 更多