如果打开设置 - >常规 - >关于,它会在屏幕顶部显示“Bob的iPhone”。你如何以编程方式抓住这个名字?如何获取iPhone的设备名称
100
A
回答
151
从类:
作为一个例子:[[UIDevice currentDevice] name];
的的UIDevice是提供有关该iPhone或iPod 触控装置 信息的类。
由 提供的部分信息UIDevice是静态的,例如设备名称或系统版本号为 。
来源:http://servin.com/iphone/uidevice/iPhone-UIDevice.html
官方文档:Apple Developer Documentation >UIDevice
Class Reference
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
相关问题
- 1. 如何获取iOS设备名称
- 2. 如何获取设备名称?
- 3. 如何在iPhone中获取设备位置名称?
- 4. 获取设备名称
- 5. 如何获取USB存储设备的设备名称?
- 6. 如何根据zenoss中的组名称获取设备名称?
- 7. iPhone蓝牙设备名称
- 8. 如何通过蓝牙获取配对MFI设备的名称到iPhone?
- 9. 从javascript获取(移动)设备名称
- 10. 获取电池设备名称
- 11. 获取网络设备名称
- 12. Corebluetooth使用Swift获取设备名称
- 13. OpenSUSE - 获取设备ID(或名称)
- 14. 如何检测捕获设备的设备名称?
- 15. 如何获取当前连接的蓝牙设备的名称?
- 16. 如何在iPhone SDK中以编程方式获取设备名称?
- 17. 获取设备标志的设备名称
- 18. 获取磁盘设备的物理设备对象名称
- 19. 从USB设备的设备路径获取卷名称
- 20. 使用HTML5获取iPad的所有者名称/设备名称
- 21. Linux和bash - 如何获取输入设备事件的设备名称?
- 22. 如何获取用户定义的设备名称与Android 4.4
- 23. 如何获取Android设备的CPU供应商名称。
- 24. 如何在Android中获取对等设备的蓝牙名称?
- 25. 如何为RawInput HID设备获取人类可读的名称?
- 26. 如何使用Python获取基于设备名称的卷标
- 27. ICS上的wifi-direct:如何获取设备名称?
- 28. 如何获取由Apple Watch跟踪的HKWorkout设备名称
- 29. 如何使用Javascript获取上传的设备名称
- 30. 如何获取Zune中定义的设备名称?
请注意:该链接的教程虽然很实用,但针对OS 2.2,并使用了3.0中不推荐使用的一些方法。 – Tim 2009-07-08 19:49:45
@Tim:你是对的。我没有想到这一点。虽然,我并不是在建议教程;我只是提供我的信息来源和更多信息的来源。 – 2009-07-08 19:58:09