如果你打开Settings -> General -> About,它会说Bob的iPhone位于屏幕顶部.你如何以编程方式获取该名称?
Fra*_*k V 173
来自UIDevice班级:
举个例子: [[UIDevice currentDevice] name];
UIDevice是一个提供有关iPhone或iPod Touch设备的信息的类.
UIDevice提供的一些信息是静态的,例如设备名称或系统版本.
来源:http://servin.com/iphone/uidevice/iPhone-UIDevice.html
官方文档: Apple开发人员文档> UIDevice类参考
Byr*_*see 83
迅速:
UIDevice.currentDevice().name
Run Code Online (Sandbox Code Playgroud)
斯威夫特3:
UIDevice.current.name
Run Code Online (Sandbox Code Playgroud)
Usm*_*sar 12
这是UIDevice的类结构
+ (UIDevice *)currentDevice;
@property(nonatomic,readonly,strong) NSString *name; // e.g. "My iPhone"
@property(nonatomic,readonly,strong) NSString *model; // e.g. @"iPhone", @"iPod touch"
@property(nonatomic,readonly,strong) NSString *localizedModel; // localized version of model
@property(nonatomic,readonly,strong) NSString *systemName; // e.g. @"iOS"
@property(nonatomic,readonly,strong) NSString *systemVersion;
Run Code Online (Sandbox Code Playgroud)
paw*_*oon 12
不幸的是,从 iOS 16 开始,您需要特殊的权利。您可以在此处请求:https ://developer.apple.com/contact/request/user-signed-device-name/

小智 10
对于 swift4.0 及以上版本使用以下代码:
let udid = UIDevice.current.identifierForVendor?.uuidString
let name = UIDevice.current.name
let version = UIDevice.current.systemVersion
let modelName = UIDevice.current.model
let osName = UIDevice.current.systemName
let localized = UIDevice.current.localizedModel
print(udid ?? "") // ABCDEF01-0123-ABCD-0123-ABCDEF012345
print(name) // Name's iPhone
print(version) // 14.5
print(modelName) // iPhone
print(osName) // iOS
print(localized) // iPhone
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
98297 次 |
| 最近记录: |