gpt4 book ai didi

ios - 如何在钛框架中检测iOS的模型

转载 作者:行者123 更新时间:2023-12-01 16:05:06 24 4
gpt4 key购买 nike

例子 :
iPad pro 第 3 代以后由于引入了底部黑条槽口。
第 1 代和第 2 代 iPad pro 中不存在。所有四代具有相同的分辨率。 1024 X 1366
如果我修复了这个决议,它将影响第一代和第二代。

if(Ti.Platform.displayCaps.platformHeight === 1366){
}
此代码会导致其他 iPad pro 代出现问题。

最佳答案

Titanium 在 Ti.Platform 命名空间中提供平台标识属性,您可以将其用于代码中的条件分支。
如果使用 Ti.Platform.model它返回模型值,但它有一些映射来准确理解哪个模型。
https://docs.appcelerator.com/platform/latest/#!/api/Titanium.Platform-property-model
以下是映射列表:

["iPod5,1": "iPod Touch 5",
"iPod7,1": "iPod Touch 6",
"iPhone3,1": "iPhone 4",
"iPhone3,2": "iPhone 4",
"iPhone3,3": "iPhone 4",
"iPhone4,1": "iPhone 4s",
"iPhone5,1": "iPhone 5",
"iPhone5,2": "iPhone 5",
"iPhone5,3": "iPhone 5c",
"iPhone5,4": "iPhone 5c",
"iPhone6,1": "iPhone 5s",
"iPhone6,2": "iPhone 5s",
"iPhone7,2": "iPhone 6",
"iPhone7,1": "iPhone 6 Plus",
"iPhone8,1": "iPhone 6s",
"iPhone8,2": "iPhone 6s Plus",
"iPhone9,1": "iPhone 7",
"iPhone9,3": "iPhone 7",
"iPhone9,2": "iPhone 7 Plus",
"iPhone9,4": "iPhone 7 Plus",
"iPhone8,4": "iPhone SE",
"iPhone10,1": "iPhone 8",
"iPhone10,4": "iPhone 8",
"iPhone10,2": "iPhone 8 Plus",
"iPhone10,5": "iPhone 8 Plus",
"iPhone10,3": "iPhone X",
"iPhone10,6": "iPhone X",
"iPhone11,2": "iPhone XS",
"iPhone11,4": "iPhone XS Max",
"iPhone11,6": "iPhone XS Max",
"iPhone11,8": "iPhone XR",
"iPhone12,1": "iPhone 11",
"iPhone12,3": "iPhone 11 Pro",
"iPhone12,5": "iPhone 11 Pro Max",
"iPad2,1": "iPad 2",
"iPad2,2": "iPad 2",
"iPad2,3": "iPad 2",
"iPad2,4": "iPad 2",
"iPad3,1": "iPad 3",
"iPad3,2": "iPad 3",
"iPad3,3": "iPad 3",
"iPad3,4": "iPad 4",
"iPad3,5": "iPad 4",
"iPad3,6": "iPad 4",
"iPad4,1": "iPad Air",
"iPad4,2": "iPad Air",
"iPad4,3": "iPad Air",
"iPad5,3": "iPad Air 2",
"iPad5,4": "iPad Air 2",
"iPad6,11": "iPad 5",
"iPad6,12": "iPad 5",
"iPad7,5": "iPad 6",
"iPad7,6": "iPad 6",
"iPad2,5": "iPad Mini",
"iPad2,6": "iPad Mini",
"iPad2,7": "iPad Mini",
"iPad4,4": "iPad Mini 2",
"iPad4,5": "iPad Mini 2",
"iPad4,6": "iPad Mini 2",
"iPad4,7": "iPad Mini 3",
"iPad4,8": "iPad Mini 3",
"iPad4,9": "iPad Mini 3",
"iPad5,1": "iPad Mini 4",
"iPad5,2": "iPad Mini 4",
"iPad6,3": "iPad Pro (9.7-inch)",
"iPad6,4": "iPad Pro (9.7-inch)",
"iPad6,7": "iPad Pro (12.9-inch)",
"iPad6,8": "iPad Pro (12.9-inch)",
"iPad7,1": "iPad Pro (12.9-inch) (2nd generation)",
"iPad7,2": "iPad Pro (12.9-inch) (2nd generation)",
"iPad7,3": "iPad Pro (10.5-inch)",
"iPad7,4": "iPad Pro (10.5-inch)",
"iPad8,1": "iPad Pro (11-inch)",
"iPad8,2": "iPad Pro (11-inch)",
"iPad8,3": "iPad Pro (11-inch)",
"iPad8,4": "iPad Pro (11-inch)",
"iPad8,5": "iPad Pro (12.9-inch) (3rd generation)",
"iPad8,6": "iPad Pro (12.9-inch) (3rd generation)",
"iPad8,7": "iPad Pro (12.9-inch) (3rd generation)",
"iPad8,8": "iPad Pro (12.9-inch) (3rd generation)",
"AppleTV5,3": "Apple TV",
"AppleTV6,2": "Apple TV 4K",
"AudioAccessory1,1": "HomePod",
"i386": "32 bit Simulator",
"x86_64": "64 bit Simulator"
]
引用: How to get device make and model on iOS?
我们可以编写代码来检测模型,例如:
在 xcode 中的虚拟设备或模拟器上运行时,它的返回类似于“iPad8,5(模拟器)”,而当实际设备返回“iPad8,5”时
if (Ti.Platform.model === "iPad8,5 (Simulator)" ||
Ti.Platform.model === "iPad8,5"){
return true;
}
else {
return false;
}
此属性不仅与 iOS 有关,它适用于所有类型的设备。我只提到了 iOS 特定的。
@miga 完成的帮助
可在此处找到更新列表: https://www.theiphonewiki.com/wiki/Main_Page
https://gist.github.com/adamawolf/3048717
获取设备 ID 的步骤:
单击设备 -> 转到相应页面
enter image description here

关于ios - 如何在钛框架中检测iOS的模型,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/63809383/

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