转自: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. iWatch应用开发-oc篇

    1.创建项目 watermark/2/text/aHR0cDovL2Jsb2cuY3Nkbi5uZXQv/font/5a6L5L2T/fontsize/400/fill/I0JBQkFCMA==/di ...

  2. 〖Android〗依据资源信息,Mock Android资源

    #!/bin/bash - #=============================================================================== # # F ...

  3. Mac Mini 2011 mid 安装Ubuntu18.06.1 Server

    在Mac mini上原来是安装的ESXi5.5, 时间比较久了, 因为内存只有8g, 跑不了几个vm, 逐渐闲置. 现在打算重新装一个Ubuntu Sever用来跑docker. 制作启动U盘 参考  ...

  4. python实现的摩斯电码解码\编码器

    代码地址如下:http://www.demodashi.com/demo/14743.html 详细说明: 现在这年头谍战片.警匪片动不动就用摩斯密码来传递信息,一方面可以用来耍帅,另外一方面好像不插 ...

  5. Android API之android.content.BroadcastReceiver

    android.content.BroadcastReceiver Base class for code that will receive intents sent by sendBroadcas ...

  6. spring下Junit_jdbc回滚demo

    配置测试类 添加如下内容在class前,用于配置applicationContext.xml文件的位置. @RunWith(SpringJUnit4ClassRunner.class) @Contex ...

  7. oracle中生成大批量数据的方法-下

    方法五:使用PLSQL的数据生成器 首先测试环境建立:dept表 CREATE TABLE dept(deptno NUMBER(6),dname VARCHAR2(20),loc VARCHAR2( ...

  8. JSP弹出对话框方式小结

    转自:http://blog.csdn.net/ithomer/article/details/8033002 该博主(创业)另一博客地址: http://blog.mimvp.com JSP 网页在 ...

  9. java struts2入门学习实例--使用struts进行验证

    一.为什么要进行验证? 验证几乎是注册登录的必须前提,验证的主要作用有两点: 1.安全性 2.对用户提供差异化服务. 二.如何验证? ActionSupport类中有一个validate()方法,这是 ...

  10. Ant scp upload文件至linux server(用java调用Ant api)

    1.要准备的jar包:ant.jar,ant-jsch.jar code: package com.test.utils; import org.apache.tools.ant.Project; i ...