简体   繁体   中英

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

I have 2 schemas in my application:

  1. App_Scheme1
  2. App_Scheme2

enter image description here

I want to use separate launch screen storyboards for them. Could you please let me know if it is possible?

I have searched regarding this and I found it is possible in the URL scheme but not in the application scheme.

I have created two different launch screen storyboards.

  1. Launch screen
  2. Dynamic Launch screen

enter image description here

How can I assign them to the schema?

Any help will be appreciated. Thanking you in advance.

You can duplicate existing app target and set it's launch screen with different launch screen then set your second scheme to run the duplicated target.

The launch storyboard is defined in Info.plist file which is generated per target. If you want to use default way of doing it, then you have to have different targets. If you want a workarounds like scripts which use configs, additional LaunchScreens in or after didFinishLaunchingWithOptions then maybe this will be possible but it will be more complex to achieve it.

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

Hmm, how about to put the desired Launch Screen on top of keyWindow of UIWindow?

UIWindow is a sub-class of UIView, so it's easy to put another UIView on top of it. Just implement these after app did finish launch.

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

As the found tutorial , iOS app 100% programmatically swift, it's UIWindow and rootController all from codes.

Go in SceneDelegate file and set your entry controller manually in willConnectTo function like this:

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
}

After that go in general and delete main like the picture below

在此处输入图像描述

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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