gpt4 book ai didi

swift - iPad 的 Launch 功能与 iPhone 的不同(在 Swift 3 中)?

转载 作者:行者123 更新时间:2023-11-28 12:33:45 25 4
gpt4 key购买 nike

我正在尝试触发我的通用 iOS 应用程序中的一个功能,仅适用于 iPad。它在 iPad 版本的应用程序上显示一组背景图像,但我不希望该功能在 iPhone 版本中运行。

所以这需要在代码中发生,我想它可能会进入 viewDidLoad() 部分,我希望我不必创建两个单独的 View Controller ?

是否有一种简单的if REGULAR height && REGULAR width 表达式?

最佳答案

您可以使用 UIDevice 检查类型

if UIDevice().model == "iPad" {
// do iPad things
} else {
// do iPhone things
}

解释:

open var model: String { get } // e.g. @"iPhone", @"iPod touch"

关于swift - iPad 的 Launch 功能与 iPhone 的不同(在 Swift 3 中)?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/41437527/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com