【问题标题】:How to set PresentingViewController with current ViewController in iOS 7+如何在 iOS 7+ 中使用当前 ViewController 设置 PresentingViewController
【发布时间】:2014-12-15 14:00:22
【问题描述】:

在我的 iOS 7+ 应用中,我使用的是最新版本的 Harpy,它会执行应用版本检查,如果 App Store 中有我的应用的新版本可用,它会发出警报。

由于我的应用程序的结构,我在调试器中遇到了这个问题:

Attempt to present <UIAlertController: 0x144538530> on <DCLoginViewController: 0x14460c1a0> whose view is not in the window hierarchy!

这是因为 harpy 是在 AppDelegate 中配置的,并且有一个参数定义了presentingViewController:

[[Harpy sharedInstance] setPresentingViewController:_window.rootViewController];

我相信问题的出现是因为我的应用程序检查用户是否已经登录,如果是这样,它不会显示 DCLoginViewController,而是跳转到下一个视图“LoadingViewController”。

如何将presentingViewController 设置为此LoadingViewController 甚至是执行时当前屏幕上的ViewController?

感谢您的帮助。

【问题讨论】:

    标签: objective-c appdelegate presentviewcontroller


    【解决方案1】:

    您不必在AppDelegate 中启动Harpy。您可以在 LoadingViewController 加载后启动它。仅建议在 AppDelegate 中启动它,因为它的想法是在应用程序加载后立即显示警报。这更像是一个 UX 的事情。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2016-01-19
      • 1970-01-01
      • 2016-07-27
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多