Hel*_*ova 3 xcode ipad ios swift
我刚刚在我的旧 iOS 项目中实现了 SceneDelegate,该项目有两个故事板 -iPhone.storyboard和iPad.storyboard. 有AppDelegate.swift和SceneDelegate.swift文件没有特定的代码 - 只是空的委托方法。
问题是,每当我使用不同的设备类型(iPhone 或 iPad)运行时,我都必须更改故事板名称。我的问题是如何将多个故事板名称设置为文件Application Scene Manifest的一部分info.plist。iPad.Storyboard当我现在用 iPhone 模拟器运行时,它显然是用文件运行的。
PS 我已经用Main storyboard file base name和设置了和Main storyboard file base name (iPad)值。iPhoneiPad
我遇到了这个问题,您需要做的是在 info.plist 中添加新的场景配置。我使用默认配置来加载 iPhone 的故事板,并添加了一种新配置来加载我的 iPad 故事板。
将“启用多个窗口”更改为“是”
然后在 AppDelegate.swift 中 -
func application(_ application: UIApplication, configurationForConnecting connectingSceneSession: UISceneSession, options: UIScene.ConnectionOptions) -> UISceneConfiguration {
// Called when a new scene session is being created.
// Use this method to select a configuration to create the new scene with.
var config = "Default Configuration"
if IS_IPAD {
print("IPAD - LOADING IPAD CONFIG - \(config)")
config = "ipad Configuration"
}
print("LOADING CONFIG - \(config)")
return UISceneConfiguration(name: config, sessionRole: connectingSceneSession.role)
}
Run Code Online (Sandbox Code Playgroud)
这为我解决了这个问题,我希望这对人们有帮助。
| 归档时间: |
|
| 查看次数: |
960 次 |
| 最近记录: |