2009-07-08 96 views

回答

151

类:

作为一个例子:[[UIDevice currentDevice] name];

的的UIDevice是提供有关该iPhone或iPod 触控装置 信息的类。

由 提供的部分信息UIDevice是静态的,例如设备名称或系统版本号为 。

来源:http://servin.com/iphone/uidevice/iPhone-UIDevice.html

官方文档:Apple Developer Documentation >UIDevice Class Reference

+2

请注意:该链接的教程虽然很实用,但针对OS 2.2,并使用了3.0中不推荐使用的一些方法。 – Tim 2009-07-08 19:49:45

+0

@Tim:你是对的。我没有想到这一点。虽然,我并不是在建议教程;我只是提供我的信息来源和更多信息的来源。 – 2009-07-08 19:58:09

175

除了上面的回答,这是实际代码:

[[UIDevice currentDevice] name];

2

为了获得iPhone的设备名称编程

UIDevice *deviceInfo = [UIDevice currentDevice]; 

NSLog(@“Device name: %@”, deviceInfo.name); 

//设备名称:我的iPod

55

斯威夫特:

UIDevice.currentDevice().name 

斯威夫特3:

UIDevice.current.name 
+1

必须有导入UIKit – DrWhat 2016-06-09 09:37:15

5

这里的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; 
4

的阶级结构xamarin用户,使用这个

UIKit.UIDevice.CurrentDevice.Name 
相关问题