Warning: Presenting view controllers on detached view controllers is discouraged

依然范特西╮ 提交于 2019-12-04 13:59:37

You need to delegate the result of the download to the top-level view controller, which sounds like your UITabBarController. The UITabBarController certainly knows which tab is selected, or it can present the alert on itself.

Write to fix warning on presenting navigation controller or VC from current VC:

[self.view.window.rootViewController presentViewController:viewController animated:YES completion:nil];

To fix crash while dismissing view controller:

[self dismissViewControllerAnimated:YES completion:nil];

OR

If you present a view from a childViewController it will give you that warning. To avoid this, you can present a view on childViewController's parent.

[self.parentViewController presentViewController:viewController animated:YES completion:nil];
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!