下面是内存溢出 jb51.cc 通过网络收集整理的代码片段。
内存溢出小编现在分享给大家,也给大家做个参考。
//// VIEwController.m// #import "VIEwController.h" @interface VIEwController ()/** * UIImageVIEw */@property(nonatomic,strong)UIImageVIEw *imageVIEw; @end @implementation VIEwController - (voID)handleDeviceOrIEntationDIDChange:(UIInterfaceOrIEntation)interfaceOrIEntation{ //1.获取 当前设备 实例 UIDevice *device = [UIDevice currentDevice] ; /** * 2.取得当前Device的方向,Device的方向类型为Integer * * 必须调用beginGeneratingDeviceOrIEntationNotifications方法后,此orIEntation属性才有效,否则一直是0。orIEntation用于判断设备的朝向,与应用UI方向无关 * * @param device.orIEntation * */ switch (device.orIEntation) { case UIDeviceOrIEntationFaceUp: NSLog(@"屏幕朝上平躺"); break; case UIDeviceOrIEntationFaceDown: NSLog(@"屏幕朝下平躺"); break; //系統無法判斷目前Device的方向,有可能是斜置 case UIDeviceOrIEntationUnkNown: NSLog(@"未知方向"); break; case UIDeviceOrIEntationLandscapeleft: NSLog(@"屏幕向左横置"); break; case UIDeviceOrIEntationLandscapeRight: NSLog(@"屏幕向右橫置"); break; case UIDeviceOrIEntationPortrait: NSLog(@"屏幕直立"); break; case UIDeviceOrIEntationPortraitUpsIDeDown: NSLog(@"屏幕直立,上下顛倒"); break; default: NSLog(@"无法辨识"); break; } } - (voID)vIEwDIDLoad { //设备名称 e.g. "My iPhone" Nsstring *strname = [[UIDevice currentDevice] name]; NSLog(@"设备名称:%@",strname); /** * 系统名称 e.g. @"iOS" */ Nsstring *strSysname = [[UIDevice currentDevice] systemname]; NSLog(@"系统名称:%@",strSysname); /** * 系统版本号 e.g. @"4.0" */ Nsstring *strSysversion = [[UIDevice currentDevice] systemVersion]; NSLog(@"系统版本号:%@",strSysversion); /** * 设备类型 e.g. @"iPhone",@"iPod touch" */ Nsstring *strModel = [[UIDevice currentDevice] model]; NSLog(@"设备类型:%@",strModel); /** * 本地设备模式 localized version of model */ Nsstring *strLocModel = [[UIDevice currentDevice] localizedModel]; NSLog(@"本地设备模式:%@",strLocModel); /** * UUID 可用于唯一地标识该设备 */ NSUUID *IDentifIErForvendor = [[UIDevice currentDevice] IDentifIErForvendor]; NSLog(@"UUID:%@",IDentifIErForvendor.UUIDString); /** * UIImage 对象 */ UIImage *image = [UIImage imagenamed:@"scroll.jpg"]; self.imageVIEw.image = image; // 设置图片范围 CGfloat imageH = image.size.height; CGfloat imageW = image.size.wIDth; CGfloat imageX = 0; CGfloat imageY = 0; self.imageVIEw.frame = CGRectMake(imageX,imageY,imageW,imageH); [self.vIEw addSubvIEw:self.imageVIEw]; [super vIEwDIDLoad]; // Do any additional setup after loading the vIEw,typically from a nib.} -(voID)vIEwDIDAppear:(BOol)animated{ /** * 开始生成 设备旋转 通知 */ [[UIDevice currentDevice] beginGeneratingDeviceOrIEntationNotifications]; /** * 添加 设备旋转 通知 * * @param handleDeviceOrIEntationDIDChange: handleDeviceOrIEntationDIDChange: description * * @return return value description */ [[NSNotificationCenter defaultCenter] addobserver:self selector:@selector(handleDeviceOrIEntationDIDChange:) name:UIDeviceOrIEntationDIDChangeNotification object:nil ]; } -(voID)vIEwDIDdisappear:(BOol)animated{ /** * 销毁 设备旋转 通知 * * @return return value description */ [[NSNotificationCenter defaultCenter] removeObserver:self name:UIDeviceOrIEntationDIDChangeNotification object:nil ]; /** * 结束 设备旋转通知 * * @return return value description */ [[UIDevice currentDevice]endGeneratingDeviceOrIEntationNotifications]; } - (voID)dIDReceiveMemoryWarning { [super dIDReceiveMemoryWarning]; // dispose of any resources that can be recreated.} #pragma 懒加载 - (UIImageVIEw *)imageVIEw{ if (!_imageVIEw) { _imageVIEw = [[UIImageVIEw alloc] init]; } return _imageVIEw;} @end
以上是内存溢出(jb51.cc)为你收集整理的全部代码内容,希望文章能够帮你解决所遇到的程序开发问题。
如果觉得内存溢出网站内容还不错,欢迎将内存溢出网站推荐给程序员好友。
总结以上是内存溢出为你收集整理的IOS UIDevice & IOS检测屏幕旋转实例全部内容,希望文章能够帮你解决IOS UIDevice & IOS检测屏幕旋转实例所遇到的程序开发问题。
如果觉得内存溢出网站内容还不错,欢迎将内存溢出网站推荐给程序员好友。
欢迎分享,转载请注明来源:内存溢出
评论列表(0条)