A superficial analysis of the mechanism of scene conversion in iOS

Source: Internet
Author: User

There are several ways that Apple has recommended scenario conversions: The General way to jump: PresentviewcontrollerDiscussion

In a horizontally compact environment, the presented view are always full screens. In a horizontally regular environment, the presentation depends on the value of the Modalpresentationstyle property.

This method sets the Presentedviewcontroller property to the specified view controller, resizes that view controller '?? s view based on the presentation style and then adds the view to the view hierarchy. The view is animated onscreen according to the transition style specified in the Modaltransitionstyle property of the Pres ented View Controller.

The completion handler is called after the Viewdidappear:method are called on the presented view Controller.

Important: The traditional modal jump method

dismissviewcontrolleranimatedDiscussion

The presenting view Controller is a responsible for dismissing the view controller it presented. If the This method is on the presented view controller itself, it automatically forwards the message to the presenting V Iew Controller.

If you present several view controllers in succession, thus building a stack of presented view controllers, calling this m Ethod on a view controllers lower in the stack dismisses their immediate child view controllers and all view controllers above That child on the stack. When this happens, only the Top-most view was dismissed in an animated fashion; Any intermediate view controllers is simply removed from the stack. The Top-most view is dismissed using its modal transition style, which could differ from the styles used by other view contr Ollers lower in the stack.

If you want to retain a reference to the receiver '?? S presented view controller, get the value in the Presentedviewcontroller property before calling this method.

The completion handler is called after the Viewdiddisappear:method are called on the presented view Controller.

Important: use with Presentviewcontroller

How to use the navigation bar to/split view: ShowviewcontrollerDiscussion

This method was used in conjunction with Uisplitviewcontroller and Uinavigationcontroller. When this method was called, it calls TargetViewControllerForAction:sender:on itself and calls this method on the returned Object. The target object can then display the view controller on an appropriate. For example, a navigation controller pushes the view controller in its navigation stack.

If the TargetViewControllerForAction:sender:method returns nil, this method uses the root of the currently presented view Controller chain to present VC modally.

Important: For Uisplitviewcontroller, Uinavigationcontroller is equivalent to calling push. If not both, it is equivalent to Presentviewcontroller

ShowdetailviewcontrollerDiscussion

This method was used in conjunction with Uisplitviewcontroller and Uinavigationcontroller. When this method was called, it calls TargetViewControllerForAction:sender:on itself and calls this method on the returned Object. The target object can then display the view controller on an appropriate. For example, a split view controller tries to display the view controller in its secondary view controller slot. If A secondary view controller already exists in this slot, that view Controller was asked to present VCs in an appropriate The.

If the TargetViewControllerForAction:sender:method returns nil, this method uses the root of the currently presented view Controller chain to present VC modally.

Important: The ipad and 6+ Splitview can display two viewcontroller in a horizontal screen, using this method

Pushviewcontroller

Pushes a view controller onto the receiver ' s stack and updates the display.

After IOS 8, Apple no longer advocates the use of Uinavigationcontroller's pushviewcontroller:animated: Method

Using show overrides

popviewcontrolleranimated

poptorootviewcontrolleranimated

Poptoviewcontroller

The above three methods are push/show corresponding to the Stack method

Other than that

In the application of the navigation controller, it is easy to access the previous controller:

   1:  let a = navigationcontroller!. Viewcontrollers
   2:  as! Contactlistviewcontroller

You can then make some modifications to its previous control

Description of the Viewcontrollers property
Property
The view controllers currently on the navigation stack.

Declaration
SWIFT
var viewcontrollers: [anyobject]!
Objective-c
@property (nonatomic, copy) Nsarray *viewcontrollers

Discussion

The root view controller is at index 0 in the array, the back view controller was at index N-2, and the top controller is a T index n-1, where n is the number of items in the array.

Assigning a new array of view controllers to this property are equivalent to calling the SetViewControllers:animated:metho D with the animated parameter set to NO.

REF:

Http://www.cocoachina.com/ios/20141113/10212.html

Http://www.cnblogs.com/iMiamas/p/4282568.html

Http://stackoverflow.com/questions/28498947/difference-between-pushviewcontroller-and-showviewcontroller

Http://mobile.51cto.com/iphone-446761.htm

Https://developer.apple.com/library/ios/documentation/UIKit/Reference/UINavigationController_Class/index.html

A superficial analysis of the mechanism of scene conversion in iOS

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.