此代碼自iOS 4以來一直運行良好。我正在執行位於主視圖控制器下方的首選項UITableViewController。當按下prefs按鈕時,主視圖向左滑動,顯示prefs表視圖。很簡單。在子視圖上呈現UIAlertController導致iOS 8中的窗口層次結構警告
其中一個首選項提出了UIActionSheet。問題是,在iOS 8中,UIActionSheet已棄用。好的,所以簡單的事情就是轉移到UIAlertController。那麼,問題是,當我點擊那個是應該彈出UIAlertController行,我得到這個:
Warning: Attempt to present <UIAlertController: 0x7cab8bf0> on <PrefsTableController: 0x7be5c5b0> whose view is not in the window hierarchy!
這並不在iOS 6中或iOS 7
的代碼的地方發生該偏好vc是:
[self.window insertSubview:prefsTableController.view belowSubview:viewController.view];
沒什麼,它的效果很好。問題是,我不明白爲什麼視圖現在被認爲是在iOS 8中被分離,當我明確地將它放置在視圖層次結構中。
呈現的UIAlertContoller的代碼是:
[self presentViewController:view animated:YES completion:nil];
所以,我在一個總損失就在這裏。如果我明確地將視圖B放在視圖A下,爲什麼我被告知視圖B不在視圖層次中?
謝謝。
什麼是'self'在'[self presentViewController:view animated:YES completion:nil];' – Kamchatka 2014-10-02 18:59:02
底部首選項視圖控制器。 – 2014-10-02 18:59:45
我使用了Xcode 6 3D窗口層次結構顯示視圖,它實際上位於正確的位置。 – 2014-10-02 19:22:36