我是 obj-c 编程的初学者,我需要知道如何显示设备信息(名称、设备类型、ios 版本)
我知道答案,请告诉我并记住我是 xcode 的初学者 ;)
最佳答案
我在我开发的应用程序中使用了这些信息,因此我编写了以下代码。我想这可能对你有帮助。我只是不明白你所说的设备类型是什么意思。
获取设备型号:
// get model from UIDevice
NSString *modelDevice = [UIDevice currentDevice].model;
获取 iOS 版本:
//get the iOS version
NSString *systemVersion = [[UIDevice currentDevice] systemVersion];
获取设备名称:
/** Method responsible to get the device name
*
* @return device Name
*/
+ (NSString *)deviceName
{
size_t size;
sysctlbyname("hw.machine", NULL, &size, NULL, 0);
char *machine = malloc(size);
sysctlbyname("hw.machine", machine, &size, NULL, 0);
NSString *platform = [NSString stringWithUTF8String:machine];
free(machine);
return platform;
}
关于ios - 如何在 iOS 上检测和显示设备信息,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/24809239/