[英]dismiss UIActionSheet when App goes in background on iOS4
在我正在處理的應用程序中,我有動作表和警報視圖,當應用程序進入非活動/后台狀態時,我想要將其視為已解除。
我正在使用UIApplicationWillResignActiveNotification而不是UIApplicationDidEnterBackgroundNotification,因為我希望代碼與iOS3.2兼容。
-(void)applicationWillResignActive:(Notification *)notification{
if (self.actionSheet && self.actionSheet.visible){
NSLog(@" actionSheet is Visible");
[self.actionSheet dismissWithClickedButtonIndex:0 animated:NO];
}
}
在模擬器(iphone 3.2,iOS4)中進行測試,看到actionSheet,我按下主頁按鈕,但我沒有得到“actionSheet is Visible”消息。 然而,當我重新打開應用程序並再次使用主頁按鈕解除它時,我得到“actionSheet is Visible”消息。
這表明第一次沒有設置actionSheet的visible屬性。 房產可能會延遲嗎? 實際上我在顯示actionSheet的方法中放了一條消息
[self.actionSheet showInView:self.parentViewController.tabBarController.view];
if (self.actionSheet.Visible) NsLog(@" action Sheet visible");
即使在這里,我也沒有收到消息。 where / when是可見屬性集? 試圖解雇actionSheet我是否做了一些根本性的錯誤? 我已經看到類似的非常好的和詳細的解決方案解決了在...中的alertViews ....但他們似乎並沒有涵蓋這個問題。 任何幫助都感激不盡。
為什么你甚至需要檢查它是否可見? 事實上,為什么你甚至需要檢查nil? 你可以把[self.actionSheet dismissWithClickedButtonIndex:0 animated:NO];
,它應該工作正常,好像動作表存在你將解雇它,如果沒有,你將只調用nil上的方法,什么都不做。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.