IOS warning about presenting view controllers on detached view controllers is discouraged

Source: Internet
Author: User

Uiimagepickercontroller *picker = [[Uiimagepickercontroller alloc] init];

[Self Presentviewcontroller:picker animated:yes completion:nil];

Into

Uiimagepickercontroller *picker = [[Uiimagepickercontroller alloc] init];

Appdelegate *delegate = (appdelegate *) [uiapplication sharedapplication].delegate;

[Delegate.window.rootViewController presentviewcontroller:picker Animated:yes completion:^{

}]; Theoretically it is allowed to present from one controller to another controller, and then from this controller present another controller.

I looked it up on the Internet. One of the great gods explained this:

In general, we present a viewcontroller content, often in the form of using Navigationcontroller and Tabbarcontroller to manage the view controller. In this case, the rendered view controller is inside an app-maintained controller stack.

In one case, a view controller can also be rendered by Self.view Addsubview:AviewController.view. While this may seem like the result of a push, the actual controller of the rendered view is not in the current app's view stack, which is called

Detachviewcontroller, if you make a present call in a view controller outside of this separation, the problem arises.

So deciding whether to split the view is to see if it is in the current app's controller stack.

Obviously app's Rootviewcontroller is on the stack, and it's the bottom-most view controller of the stack. So this kind of solution is to some extent feasible.

Related Article

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.