转自:http://stackoverflow.com/questions/6695837/push-uiviewcontroller-with-different-orientation-to-previous

参考:http://stackoverflow.com/questions/15947349/how-to-handle-different-orientations-in-ios/16022631#16022631

It makes no sense to use a UINavigationController push transition to present a view in a different orientation. Which way round would the navigation bar / toolbar be?

Presenting a modal view controller is the right way to go about this. If this causes the status bar to become hidden, make sure yourModalViewController.wantsFullScreenLayout is NO.

Using -[UIDevice setOrientation:] is a private API, and will get your application rejected. See this question.

What you ask is not possible using public API and is also not recommended from HIG standpoint. What is supported and you should implement, is modal presentation of the different view controllers with different supported interface orientation. This is why the default implementation of UINavigationController is to always rotate; it assumes all view controllers have the same supported interface orientations.

Take for example video playback on iPhone. Open the video apps (that comes with iOS). The root view controller only supports portrait orientation. However, start a video, and a modal view controller pops up which only supports landscape interface orientations. This seems exactly the behavior you wish to achieve.

This is why preferredInterfaceOrientationForPresentation is not called. preferredInterfaceOrientationForPresentation only gets called when using presentViewController:animated:.

A small gotcha, if you require a navigation bar in each stage of your scene, you will need to enclose each modal view controller with a navigation controller. You can then pass the required data in prepareForSegue: by accessing topViewController of the navigation controller object in the segue.

Here is an example project which behaves correctly according to your requirements (or at least will give you ideas how to implement):

http://www.mediafire.com/?zw3qesn8w4v66hy

Push UIViewController with different orientation to previous的更多相关文章

  1. iOS屏幕旋转 浅析

    一.两种orientation 了解屏幕旋转首先需要区分两种orientation 1.device orientation 设备的物理方向,由类型UIDeviceOrientation表示,当前设备 ...

  2. GeSHi Documentation

    GeSHi Documentation Version 1.0.8.11 Authors: © 2004 - 2007 Nigel McNie © 2007 - 2012 Benny Baumann ...

  3. Tracing SQL Queries in Real Time for MySQL Databases using WinDbg and Basic Assembler Knowledge

    https://www.codeproject.com/Articles/43305/Tracing-SQL-Queries-in-Real-Time-for-MySQL-Databas     As ...

  4. MXNet源码分析 | KVStore进程间通信

    本文主要基于MXNet1.6.0版本进行分析. 在上一篇文章中,我们分析了MXNet中KVStore的进程内通信机制.在这篇文章中,我们主要分析KVStore如何进行多节点分布式通信. 在KVStor ...

  5. UIViewController push或presentViewController 弹出方式

    //导航控制器数量 add xjz 判断是push还是present出来的 NSArray *viewcontrollers = self.navigationController.viewContr ...

  6. ios swift 判断uiviewcontroller时push present 进来的 还是pop进来的

    override func viewWillAppear(_ animated: Bool) { super.viewWillAppear(animated) //显示navbar self.navi ...

  7. IOS - Create Push Segue Animation Without UINavigationController

    APPLE提供了三种storyboard segue的方式:push,modal,custom . push segue是系统预定义的跳转方式, 为了使其能正常工作,我们还必须加载UINavigati ...

  8. UIViewController所有API的学习。

    <欢迎大家加入iOS开发学习交流群:QQ529560119> /*      UIViewController is a generic controller base class tha ...

  9. Mobile Push Notification

    In one embodiment, a method includes sending to a mobile client computing device a first notificatio ...

随机推荐

  1. 5、redis之使用spring集成commons-pool

    添加spring的依赖 <project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://w ...

  2. Axure 富文本框

    百度网盘:http://pan.baidu.com/s/1c1ZjUPq

  3. Linux默认日志含义

    Linux系统日志: /var/log/secure∶ 记录登入系统存取资料的档案,例如 pop3, ssh, telnet, ftp 等都会记录在此档案中: /var/log/wtmp∶ 记录登入者 ...

  4. 1万字!彻底看懂微信小程序

    Q:为什么说小程序如炮友? A:小程序刚发布不久就流行一个段子:APP如原配,一年不用几次:服务号如情人,一个月固定几次:订阅号如酒店小卡片,天天可以卖广告:小程序像炮友,用完就走. 资本如嫖客,各个 ...

  5. \u Unicode和汉字转化

    介绍 \uxxxx这种格式是Unicode写法,表示一个字符,其中xxxx表示一个16进制数字,范围所0-65535. Unicode十六进制数只能包含数字0-9.大写字母A-F或者小写字母A-F.需 ...

  6. 导致线程死锁容易忽略的一点 SendMessage

    假如主线程 某一个按钮 点击的 响应要操作与另一个线程共享的 变量. 在这个点击响应里先lock 之后,假如另一个线程的变量正在 “使用”状态,并且内部又调用了SendMessage试图更新界面的某些 ...

  7. 转:Spring Cache抽象详解

    缓存简介 缓存,我的理解是:让数据更接近于使用者:工作机制是:先从缓存中读取数据,如果没有再从慢速设备上读取实际数据(数据也会存入缓存):缓存什么:那些经常读取且不经常修改的数据/那些昂贵(CPU/I ...

  8. VS2010调试多进程

    http://msdn.microsoft.com/zh-cn/library/ms123401.aspx 选择启动项目 在“解决方案资源管理器”中,右击项目名,然后在快捷菜单上单击“设为启动项目”. ...

  9. ML之监督学习算法之分类算法一 ——— 决策树算法

    一.概述 决策树(decision tree)的一个重要任务是为了数据中所蕴含的知识信息,因此决策树可以使用不熟悉的数据集合,并从中提取出一系列规则,在这些机器根据数据创建规则时,就是机器学习的过程. ...

  10. Java使用Itext5.5.10进行pdf签章

    说到PDF数字签名签章,这个其实也是数字证书信息安全的应用范畴,关于数字证书和数字签名,网上有很多解释说明,但讲解都多不够详细准确,这边推荐一篇大神的博文,讲解浅显易懂形象数字证书 数字签名 数据加密 ...