2014-11-04 53 views
2

可悲的是我不得不從UIActionSheet遷移到UIAlertController,因爲IOS8刪除了第一個功能。雖然顯示UIAlertController,父母的viewDidDisappear沒有被調用(只在IOS8上)

在使用之前,我每次去主屏幕,父母的視圖「viewDidDisappear」被調用,所以我可以關閉我創建的菜單。

現在它不再被調用。 代碼如下:

UIAlertController *alert = [UIAlertController .... preferredStyle:UIAlertControllerSTyleActionSheet] 
UIAlertAction* a = [....] 
[alert addAction: a]; 
alert.popoverPresentationController.barButtonItem = self.myButton // the bar button from my view 
[self presentViewController:alert animated:YES completion:nil] // maybe im not showing the view well? 

我不知道如何從這裏繼續..會喜歡一些幫助 感謝。

== ==編輯

我看到它與過時UIActionSheet也恰好也與UIDcoumentInteractionController - 只有在iOS8上,而不是在IO7

+0

代碼我也有同樣的困惑。也許蘋果開發人員認爲它是透明的,所以它並沒有真正消失。 – 2017-11-24 07:30:17

回答

0

也許我想得簡單在這裏,但止跌如果將你在獨立方法中使用的任何代碼放在viewDidDisappear中,並且在用於呈現該警報控制器的那段代碼之後調用該方法,最簡單嗎?

- (void)viewDidDisappear { 
    [self hideMenu]; 
} 

- (void)hideMenu { 
    // Do all stuff to hide the menu you previously did in viewDidDisappear 
} 

及變更該呈現這樣

// more code here 
[self presentViewController:alert animated:YES completion:nil]; 
[self hideMenu]; 
+0

但是如果我在顯示後立即調用hideMenu,它不會馬上關閉窗口? 此外,當我移動到主屏幕時,不應該調用viewDidDisappear? – ArielB 2014-11-04 14:52:11

+0

可能我不瞭解你的真正問題,因爲你的問題有點不太適合 – 2014-11-04 17:05:44

+0

我可以提供更多信息嗎?據我瞭解,當主屏幕回來時,視圖應該調用「viewDidDisappear」和「viewDidAppear」。 如果顯示UIAlertController(在上面的代碼中),我會回到主屏幕,然後回到應用程序 - 這些功能不再被調用。 這只是在IOS8的方式 – ArielB 2014-11-05 11:48:02

相關問題