在 iOS 开发中,你可以通过以下方式判断当前设备是否是 iPad:

Objective-C 代码:

if ([[UIDevice currentDevice] userInterfaceIdiom] == UIUserInterfaceIdiomPad) {
    // 是 iPad
} else {
    // 不是 iPad
}

Swift 代码:

if UIDevice.current.userInterfaceIdiom == .pad {
    // 是 iPad
} else {
    // 不是 iPad
}

以上代码会根据当前设备的用户界面风格判断是否是 iPad。

iOS 判断设备是否是 iPad (Objective-C & Swift)

原文地址: https://www.cveoy.top/t/topic/bhqp 著作权归作者所有。请勿转载和采集!

免费AI点我,无需注册和登录