ios - 警告 :-Presenting view controllers on detached view controllers is discouraged

标签 ios iphone cocoa-touch ios7 warnings

在我的应用中,我使用了导航 Controller 。稍后在某些 View 中,我使用 presentViewController 来显示缩放图像。 我也没有使用 Storyboard 或 Nib 。

我仅在 iOS 7 中遇到此错误。它在 iOS 6 及更早版本中运行良好:

Presenting view controllers on detached view controllers is discouraged

最佳答案

为避免在推送导航中收到警告,您可以直接使用:

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

然后在你的模态视图 Controller 中,当一切都完成后,你可以调用:

[self dismissViewControllerAnimated:YES completion:nil];

关于ios - 警告 :-Presenting view controllers on detached view controllers is discouraged,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/19890761/

相关文章:

iOS 企业开发者帐户和公共(public)测试版?

ios - 如果内容大小 > 实际高度则固定高度,如果内容大小 < 实际高度那么 tableview swift 3 的动态?

ios - 拖动 uiview iOS

iphone - UIImageView 不遵循 origin.x 位置

iPhone - URL 有效性的 Reg Exp

javascript - jquery 单击事件不会在 iPhone 中的按钮元素上触发

ios - NSNotificationCenter 'selector' working than once is single 网络状态变化

iPhone/iPad 键盘快捷键?

ios - 如何捕获包含所有内容的 UIWebview 的屏幕截图?

ios - addressDictionary 已弃用 : first deprecated in iOS 11. 0 - 使用@properties