@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; // e.g. @"4.0"
@property(nonatomic,readonly) UIDeviceOrientation orientation; // return current device orientation. this will return UIDeviceOrientationUnknown unless device orientation notifications are being generated.
测试:
NSLog(@"%@", device.name); //用户自定义终端名
NSLog(@"%@", device.model); //型号名
NSLog(@"%@", device.localizedModel); //本地型号名
NSLog(@"%@", device.systemName); //OS名
NSLog(@"%@", device.systemVersion); //OS版本
NSLog(@"%ld", (long) device.orientation);//屏幕方向
输出:
2016-01-04 14:20:28.319 01-Myproject[711:11710] iPhone Simulator
2016-01-04 14:20:28.320 01-Myproject[711:11710] iPhone
2016-01-04 14:20:28.320 01-Myproject[711:11710] iPhone
2016-01-04 14:20:28.321 01-Myproject[711:11710] iOS
2016-01-04 14:20:28.321 01-Myproject[711:11710] 9.1
2016-01-04 14:20:28.321 01-Myproject[711:11710] 0
其中屏幕方向:
typedef NS_ENUM(NSInteger, UIDeviceOrientation) {
UIDeviceOrientationUnknown,
//未知方向
UIDeviceOrientationPortrait, // Device oriented vertically, home button on the bottom
//屏幕直立
UIDeviceOrientationPortraitUpsideDown, // Device oriented vertically, home button on the top
//屏幕直立,上下颠倒
UIDeviceOrientationLandscapeLeft, // Device oriented horizontally, home button on the right
//屏幕向左横置
UIDeviceOrientationLandscapeRight, // Device oriented horizontally, home button on the left
//屏幕向右横置
UIDeviceOrientationFaceUp, // Device oriented flat, face up
//屏幕朝上平躺
UIDeviceOrientationFaceDown // Device oriented flat, face down
//屏幕朝下平躺
};