繁体   English   中英

iOS:我们可以在 iOS 应用程序中为不同的架构使用不同的启动屏幕 storyboard

[英]iOS: Can we use different launch screen storyboard for different schema in iOS Application

我的应用程序中有 2 个模式:

  1. App_Scheme1
  2. App_Scheme2

在此处输入图像描述

我想为他们使用单独的启动屏幕故事板。 如果可能的话,你能告诉我吗?

我已经对此进行了搜索,发现在 URL 方案中有可能,但在应用程序方案中没有。

我创建了两个不同的启动屏幕故事板。

  1. 启动画面
  2. 动态启动屏幕

在此处输入图像描述

如何将它们分配给架构?

任何帮助将不胜感激。 提前谢谢你。

您可以复制现有的应用程序目标并将其启动屏幕设置为不同的启动屏幕,然后设置您的第二个方案来运行复制的目标。

启动 storyboard 在每个目标生成的 Info.plist 文件中定义。 如果你想使用默认方式,那么你必须有不同的目标。 如果你想要一个解决方法,比如使用配置的脚本,在didFinishLaunchingWithOptions中或之后的额外 LaunchScreens 那么也许这是可能的,但实现它会更复杂。

<key>UILaunchStoryboardName</key>
    <string>LaunchScreen</string>

嗯,如何将所需的Launch Screen放在 UIWindow 的keyWindow之上?

UIWindow是 UIView 的子类,所以很容易在它上面再放一个 UIView。 只需在应用程序完成启动后实施这些。

// AppDelegate callback after app did launch.
func application(application: UIApplication, 
           didFinishLaunchingWithOptions: launchOptions: [NSObject: AnyObject]?) -> Bool

作为找到的教程,iOS app 100% programmatically swift,它的UIWindowrootController都来自代码。

SceneDelegate 文件中的 Go 并在 willConnectTo function 中手动设置条目 controller,如下所示:

func scene(_ scene: UIScene, willConnectTo session: UISceneSession, options connectionOptions: UIScene.ConnectionOptions) {
    // Use this method to optionally configure and attach the UIWindow `window` to the provided UIWindowScene `scene`.
    // If using a storyboard, the `window` property will automatically be initialized and attached to the scene.
    // This delegate does not imply the connecting scene or session are new (see `application:configurationForConnectingSceneSession` instead).
    guard let windowScene = (scene as? UIWindowScene) else { return }
    
    window = UIWindow(windowScene: windowScene)
    window?.backgroundColor = .white
    window?.makeKeyAndVisible()
    let controller = YourPrfereStartController() // set here the name of controller that you want to start
    window?.rootViewController = controller
}

之后一般为 go 并删除 main 如下图

在此处输入图像描述

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM