簡體   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