在父视图控制器里面写如下代码

-(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;

}

 

最新文章

  1. 统一的Json组件和csv下载组件
  2. Windows系统
  3. PowerDesigner连接Oracle数据库生成数据模型【数据源连接方式】
  4. 如何在WTL和MFC中使用duilib及如何静态使用duilib库!(初级讲解 附带一个Demo)
  5. JSBinding + SharpKit / 实战:转换 2DPlatformer
  6. Server Error The server encountered an error and could not complete your request. 新建站点模版失败
  7. 设置MAVEN_OPTS环境变量
  8. [Oracle] - 性能优化工具(4) - AWRDD
  9. Youtube最佳Red5 官方视频下载指南,字幕【亲测成功】
  10. java web 学习总结之 Servlet/JSP 编码问题
  11. 【Codeforces AIM Tech Round 4 (Div. 2) C】
  12. Odoo-10开发环境配置与测试
  13. Mike and palindrome CodeForces - 798A
  14. LibreOJ #6014. 「网络流 24 题」最长 k 可重区间集
  15. JavaSE 字符串和正则表达式
  16. Xcode添加全局引用文件pch
  17. Servlet----------ServletContext (重要)
  18. Android 美学设计基础 <3>
  19. 5.5版本以上”No input file specified“问题解决
  20. TCP系列49—拥塞控制—12、DSACK下的拥塞撤销

热门文章

  1. JAVA & C++ 多态
  2. JS编写类似弹出窗口样式显示层
  3. 【转】Python的hasattr() getattr() setattr() 函数使用方法详解
  4. LeetCode:旋转图像【48】
  5. bootstrap插件实用方法
  6. 动手动脑:String.equals()的使用方法
  7. 每天一个Linux命令(50)netstat命令
  8. css背景透明文字不透明
  9. 发送ajax请求实现上传图片显示在网页上
  10. JMeter学习(八)JDBC Request