本文介绍了pushViewController和showViewController之间的区别的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

UINavigationController上的pushViewController和showViewController方法之间有什么区别?

What's the difference between pushViewController and showViewController methods on UINavigationController?

推荐答案

显示segue可以与导航控制器一起使用,它们只是将viewController推送到您的堆栈上.

Show segue can be used with navigation controllers, they simply push viewControllers on your stack.

显示详细信息segue仅对拆分视图控制器有意义.由于您的拆分视图控制器中有两个viewControllers,因此您可以:

Show detail segue has only sense with split view controllers. Since you have two viewControllers inside your split view controller you can:

通过使用Show segue呈现(推动,因为默认项目将NavigationVC作为主VC)来显示视图控制器,从而在主视图控制器中进行导航使用显示详细信息"在详细信息视图控制器中显示详细信息如果您不知道拆分视图控制器是如何组成的:

navigate in your master view controller by presenting (pushing, since the default project uses a navigationVC as master VC) view controllers with Show segueshow details in your detail view controller with Show detail segueIn case you don't know how a Split view controller is composed:

**************++++++++++++++++++
*            *                 +
*            *                 +
*   master   *      detail     +
*    view    *       view      +
* controller *    controller   +
*            *                 +
*            *                 +
**************++++++++++++++++++

但是!

在iPhone上的显示方式如下(不包括iPhone6 +风景)

On iphones it's presented like this (iPhone6+ landscape excluded)

****************
*++++++++++++++*
*+            +*
*+            +*
*+            +*
*+   detail   +*
*+    view    +*
*+ controller +*
*+            +*
*+            +*
*++++++++++++++*
****************

Showsegue Show detail segue 都是 iOS8 &中的新功能. Xcode6 ,它们被称为 adaptative segues ,它们的行为取决于设备类型或方向.

Both of Showsegue and Show detail segue are new to iOS8 & Xcode6, they are called adaptative segues, they behaves differently depending on the device type or the orientation.

基本上,由于没有太多空间可以并排显示视图控制器,因此 Show segue 和Show detail segue在iPhone上似乎具有相同的作用.

Basically, Show segue and Show detail segue seems to do the same thing on iPhones, since there is no much space to present view controllers side by side.

从技术上讲,直到您返回导航时,您才会多次显示详细信息.只有主视图控制器才应执行显示详细信息序列",详细视图控制器应为导航树中的叶子(但禁止将NavigationVC用作叶子;))

Technically, you don't present details several times until you go back in your navigation. Only the master view controller should perform Show detail segues, a detail view controller should be a leaf in your navigation tree (but it's not forbidden to use a navigationVC as a leaf ;) )

希望有帮助.

这篇关于pushViewController和showViewController之间的区别的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

10-29 16:31