Determine device (iPhone, iPod Touch) with iOS

后端 未结 30 1809
礼貌的吻别
礼貌的吻别 2020-11-21 11:29

Is there a way to determine the device running an application. I want to distinguish between iPhone and iPod Touch, if possible.

30条回答
  •  梦谈多话
    2020-11-21 12:13

    I'd like to add that to retrieve the front and enclosure color of the device there's a private API:

    UIDevice *device = [UIDevice currentDevice];
    SEL selector = NSSelectorFromString([device.systemVersion hasPrefix:@"7"] ? @"_deviceInfoForKey:" :  @"deviceInfoForKey:");
    if ([device respondsToSelector:selector]) {
        NSLog(@"DeviceColor: %@ DeviceEnclosureColor: %@", [device performSelector:selector withObject:@"DeviceColor"], [device performSelector:selector withObject:@"DeviceEnclosureColor"]);
    }
    

    I've blogged about this and provide a sample app:

    http://www.futuretap.com/blog/device-colors/

提交回复
热议问题