使用通知监听屏幕的旋转可以有效的避免viewcontrollor判断转向错误的问题
来源:互联网 发布:linux 禁用独显 编辑:程序博客网 时间:2024/06/03 16:54
-(void)viewWillAppear:(BOOL)animated{ UIDevice *device = [UIDevice currentDevice]; //Get the device object [device beginGeneratingDeviceOrientationNotifications]; //Tell it to start monitoring the accelerometer for orientation NSNotificationCenter *nc = [NSNotificationCenter defaultCenter]; //Get the notification centre for the app [nc addObserver:self selector:@selector(orientationChanged:) name:UIDeviceOrientationDidChangeNotification object:device];}-(void)viewWillDisappear:(BOOL)animated { NSNotificationCenter *nc = [NSNotificationCenter defaultCenter]; UIDevice *device = [UIDevice currentDevice]; //Get the device object [nc removeObserver:self name:UIDeviceOrientationDidChangeNotification object:device];}- (void)orientationChanged:(NSNotification *)note { UIDeviceOrientation status= [[UIDevice currentDevice] orientation]; switch (status) { case UIDeviceOrientationPortrait: // Device oriented vertically, home button on the bottom [self dismissViewControllerAnimated:YES completion:nil]; break; case UIDeviceOrientationPortraitUpsideDown: // Device oriented vertically, home button on the top break; case UIDeviceOrientationLandscapeLeft: // Device oriented horizontally, home button on the right ; break; case UIDeviceOrientationLandscapeRight: // Device oriented horizontally, home button on the left ; break; default: break; }}
0 0
- 使用通知监听屏幕的旋转可以有效的避免viewcontrollor判断转向错误的问题
- Android屏幕旋转使用OrientationEventListener的监听
- 关于屏幕旋转的问题
- 关于屏幕的旋转问题
- 屏幕自动旋转的问题
- 屏幕自动旋转的问题
- 十个可以避免的面试错误
- 十个可以避免的面试错误
- 十个可以避免的面试错误
- android屏幕转向onConfigurationChanged不执行的问题
- iOS监听屏幕旋转的几种方法
- 通知的使用和通知对键盘的监听
- null值判断的一个避免错误
- Struts的转向问题
- 使用int rotation = mActivity.getWindowManager().getDefaultDisplay().getRotation();可以获取屏幕旋转的方向
- 关于iOS6.0 屏幕旋转的问题
- iOS 6.0屏幕旋转的问题
- 关于IOS屏幕的旋转问题
- uitableview重用机制研究(转载了下,学习用)
- Python内置函数进制转换的用法
- Linux服务器之信号的使用
- 虚拟机centos安装vmware tools
- 在ubuntu 14.04 下安装LAMP过程
- 使用通知监听屏幕的旋转可以有效的避免viewcontrollor判断转向错误的问题
- Android去标题和实现全屏
- 好吃的豆角回锅肉啊http://www.haodou.com/recipe/510485
- [小技巧] ls 结果输出
- jquery 获得元素的 xy坐标,不知道可不可用
- 在eclipse下使用java调用weka
- 非洲有多大,它比你在地图上看到的要大的多
- Linux系统编程(31)—— socket编程之TCP详解
- Python 获取Google+特定用户最新动态