iOS 一个页面支持一个方向上横屏,其他页面全部竖屏
来源:互联网 发布:unity3d 重新加载场景 编辑:程序博客网 时间:2024/05/01 13:08
1,项目中开启横竖屏
2,自定义一个 UINavigationController ,并实现以上几个方法
- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)toInterfaceOrientation{ UIViewController *vc = self.topViewController; if([vc isKindOfClass:[RemoteController class]]){//要横屏的界面 return (toInterfaceOrientation == UIInterfaceOrientationLandscapeRight); } return (toInterfaceOrientation == UIInterfaceOrientationPortrait);}- (BOOL)shouldAutorotate{ UIViewController *vc = self.topViewController; if([vc isKindOfClass:[RemoteController class]]){//要横屏的界面 return YES; } //横屏的上一个界面,要返回为YES,否则横屏返回的时候上一界面不能还原成竖屏 if([vc isKindOfClass:[ConnectHome class]]){ return YES; } return NO;}- (NSUInteger)supportedInterfaceOrientations{ UIViewController *vc = self.topViewController; if([vc isKindOfClass:[RemoteController class]]){//要横屏的界面 return UIInterfaceOrientationMaskLandscapeRight; } return UIInterfaceOrientationMaskPortrait;}
3,在需要横屏的界面
//进入界面时强制横屏- (void)viewWillAppear:(BOOL)animated{ if ([[UIDevice currentDevice] respondsToSelector:@selector(setOrientation:)]) { SEL selector = NSSelectorFromString(@"setOrientation:"); NSInvocation *invocation = [NSInvocation invocationWithMethodSignature:[UIDevice instanceMethodSignatureForSelector:selector]]; [invocation setSelector:selector]; [invocation setTarget:[UIDevice currentDevice]]; int val = UIInterfaceOrientationLandscapeRight; [invocation setArgument:&val atIndex:2]; [invocation invoke]; }}//退出界面时强制竖屏- (void)viewWillDisappear:(BOOL)animated{ if ([[UIDevice currentDevice] respondsToSelector:@selector(setOrientation:)]) { SEL selector = NSSelectorFromString(@"setOrientation:"); NSInvocation *invocation = [NSInvocation invocationWithMethodSignature:[UIDevice instanceMethodSignatureForSelector:selector]]; [invocation setSelector:selector]; [invocation setTarget:[UIDevice currentDevice]]; int val = UIDeviceOrientationPortrait; [invocation setArgument:&val atIndex:2]; [invocation invoke]; }}
0 0
- iOS 一个页面支持一个方向上横屏,其他页面全部竖屏
- iOS中如何实现单个页面支持横竖屏(其他页面只能竖屏)
- iOS中如何实现单个页面支持横竖屏(其他页面只能竖屏)
- iOS中如何实现单个页面支持横竖屏(其他页面只能竖屏)
- 支持一个页面横屏的方法
- iOS 个别页面强制横屏,其他页面竖屏
- iOS 个别页面强制横屏,其他页面竖屏
- iOS 个别页面强制横屏,其他页面竖屏
- IOS 一个页面中多个tableview
- 关于在一个页面去finish其他的页面,也可以调用其他页面的方法
- 在UINavigationController下只要一个页面支持转屏
- 支持单一页面可以横屏的一个坑
- iOS-一个页面多个请求完成以后再执行其他操作
- 当一个页面全部加载完才触发的事件
- nginx 将请求全部指向到一个页面
- Java捕获一个网站页面的全部图片
- qt 关闭一个页面,结束应用程序运行,关闭其他窗口
- html前端如何将一个页面表单内的数据全部传递到另一个页面?
- CCF 201503-4网络延时 (树的直径)
- 11.6 Matlab MEX 文件的编写与调试
- Spring常见问题汇总
- windows10配置IIS后无法访问根目录外的其他目录
- RBAC权限管理
- iOS 一个页面支持一个方向上横屏,其他页面全部竖屏
- python__文件
- LeetCode || Add Digits
- Codeforces 513B Permutations
- OpenCV学习:HOG+SVM物体分类
- 浅谈阅读LINUX内核源码
- HDU 2608 0 or 1 简单数论
- linux上安装redis数据库,并实现 java连接redis一路遇到的错误
- uva 11093 Just Finish it up (环形跑道水题_模拟)