0
在模態創建的視圖中,按下按鈕會導致模態視圖關閉,並加載另一個模態視圖。從另一個模態視圖創建模態視圖失敗
DenkoStation[4259:73173] Warning: Attempt to present <LanguageSelectionViewController: 0x7b185430> on <ViewController: 0x79f52e50> whose view is not in the window hierarchy!
最讓我驚訝的是,之前我做了一些改變,以我的代碼as outlined here代碼愉快地運行的事實:當這個代碼塊執行拋出
- (void)loadLanguageSelectionView {
[self dismissViewControllerAnimated:YES completion:nil];
UIViewController *languageSelectionController = [[LanguageSelectionViewController alloc] initWithNibName:nil bundle:nil];
[languageSelectionController setModalPresentationStyle:UIModalPresentationCustom];
[languageSelectionController setModalTransitionStyle:UIModalTransitionStyleCrossDissolve];
[self presentViewController:languageSelectionController animated:YES completion:nil];
}
以下錯誤。
哪裏出錯?
您關閉該視圖控制器後,它不再是層次結構,所以錯誤。如果您首先獲得呈現視圖控制器,然後在調用'presentViewController:'時將其用作接收器,會怎麼樣? (不是一個答案,因爲我沒有嘗試過......但它似乎是合理的。) –
問題是你先解僱'self',使用'[self dismissViewControllerAnimated:YES completion:nil];'然後你試着提出'self'上的'languageSelectionController'。這就是爲什麼如果失敗。 – x4h1d
@PhillipMills它的工作原理。謝謝。如果您將解決方案寫成答案,我會選擇它作爲正確答案。 –