iOS:我们可以为 iOS 应用程序中的不同架构使用不同的启动屏幕情节提要吗

问题描述 投票:0回答:3

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

  1. 应用_方案1
  2. 应用_方案2

在此输入图片描述

我想为它们使用单独的启动屏幕故事板。如果可以的话请告诉我好吗?

我对此进行了搜索,发现在 URL 方案中可以,但在应用程序方案中不行。

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

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

在此输入图片描述

如何将它们分配给架构?

任何帮助将不胜感激。预先感谢您。

ios swift launch-screen
3个回答
0
投票

嗯,将所需的

Launch Screen
放在 UIWindow 的
keyWindow
之上怎么样?

UIWindow是UIView的子类,因此很容易将另一个UIView放在它上面。只需在应用程序完成启动后实施这些即可。

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

正如找到的教程,iOS应用程序100%以编程方式快速,它的

UIWindow
rootController
全部来自代码。


0
投票

进入 SceneDelegate 文件并在 willConnectTo 函数中手动设置入口控制器,如下所示:

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
}

之后进入general并删除main,如下图所示

enter image description here


0
投票

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

启动故事板在每个目标生成的 Info.plist 文件中定义。如果你想使用默认的方式来做到这一点,那么你必须有不同的目标。如果您想要一个解决方法,例如使用配置的脚本,在

didFinishLaunchingWithOptions
中或之后添加额外的 LaunchScreen,那么也许这是可能的,但实现它会更复杂。

<key>UILaunchStoryboardName</key>
    <string>LaunchScreen</string>
© www.soinside.com 2019 - 2024. All rights reserved.