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 - 如何在iOS中识别不同连接的 watch

objective-c - 将元素放入部分数组的大条件,更好的方法吗? - Objective-C

Objective-C block 和变量范围

iphone - 如何通过代码从应用程序更新 localized.strings ?

ios - UICollectionViewController 的 UICollectionView 必须是它的根 UIView 吗?

iphone - 抛硬币平滑过渡

iphone - 为什么 .xib 文件初始化尽管我 initWithNibFile : nil

ios - 如何自动布局并将应用程序部署到应用程序商店

iphone - 删除后的核心数据在保存时抛出错误

ios - 使用自动布局将 UIButtons 设置为等距离