2013-09-21 41 views
0

嘗試顯示UIPopoverController在ios 7中崩潰,而它在ios6和之前工作。該錯誤消息是ios7 NSInvalidArgumentException提供UIPopoverController

終止應用程序由於未捕獲的異常「NSInvalidArgumentException」,原因:「 - [UIPopoverController _commonPresentPopoverFromRect:inView:permittedArrowDirections:動畫:]:Popovers不能由不具有窗口的視圖中。 「

事實上,這是真的:self.view.window在ios7中爲零,但在ios6中爲零。

的代碼:

UIPopoverController *pop = [[UIPopoverController alloc] initWithContentViewController:aViewCtl]; 
pop.delegate = self; 
[pop presentPopoverFromRect:CGRectMake(aRect inView:self.view permittedArrowDirections:UIPopoverArrowDirectionAny animated:YES]; 

該視圖中創建(和分配給self.view)編程在的loadView方法中,當按下按鈕之後顯示的酥料餅。任何建議?

編輯:看起來像問題是顯示彈出窗口之前使用模態視圖,儘管解僱它。不知怎的,self.view.window在呈現之後會丟失。

回答

0

我發現的最佳解決方案是檢查self.view.window。如果它是零,則在視圖中註冊一個委託並等待didMoveToWindow,這將調用委託並繼續創建並顯示反彈。

相關問題