ios6,ios7强制转屏
2024-10-12 10:30:08
在父视图控制器里面写如下代码
-(void)setViewOrientation:(UIInterfaceOrientation )orientation
{
if ([[UIDevice currentDevice] respondsToSelector:@selector(setOrientation:)]) {
[[UIDevice currentDevice] performSelector:@selector(setOrientation:)
withObject:(id)orientation];
}
[UIViewController attemptRotationToDeviceOrientation];//这句是关键
} -(NSUInteger)supportedInterfaceOrientations
{
return UIInterfaceOrientationMaskPortrait;
} -(BOOL)shouldAutorotate
{
return YES;
} - (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)toInterfaceOrientation
{
return toInterfaceOrientation==UIInterfaceOrientationPortrait;
}
在子视图控制器的加入,这里子视图控制器要横屏
- (void)viewWillAppear:(BOOL)animated
{
[super viewWillAppear :YES];
[self setViewOrientation:UIInterfaceOrientationLandscapeRight];
}
//重写下面子类的方法
- (NSUInteger) supportedInterfaceOrientations{
returnUIInterfaceOrientationMaskLandscapeRight;
}
- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)toInterfaceOrientation NS_DEPRECATED_IOS(2_0, 6_0){
return toInterfaceOrientation == UIInterfaceOrientationLandscapeRight;
}
最新文章
- 统一的Json组件和csv下载组件
- Windows系统
- PowerDesigner连接Oracle数据库生成数据模型【数据源连接方式】
- 如何在WTL和MFC中使用duilib及如何静态使用duilib库!(初级讲解 附带一个Demo)
- JSBinding + SharpKit / 实战:转换 2DPlatformer
- Server Error The server encountered an error and could not complete your request. 新建站点模版失败
- 设置MAVEN_OPTS环境变量
- [Oracle] - 性能优化工具(4) - AWRDD
- Youtube最佳Red5 官方视频下载指南,字幕【亲测成功】
- java web 学习总结之 Servlet/JSP 编码问题
- 【Codeforces AIM Tech Round 4 (Div. 2) C】
- Odoo-10开发环境配置与测试
- Mike and palindrome CodeForces - 798A
- LibreOJ #6014. 「网络流 24 题」最长 k 可重区间集
- JavaSE 字符串和正则表达式
- Xcode添加全局引用文件pch
- Servlet----------ServletContext (重要)
- Android 美学设计基础 <;3>;
- 5.5版本以上”No input file specified“问题解决
- TCP系列49—拥塞控制—12、DSACK下的拥塞撤销