In the application I'm working on, I have action sheets and warnings that I would reject when the application goes into an inactive / background state.
I use UIApplicationWillResignActiveNotification instead of UIApplicationDidEnterBackgroundNotification, since I want the code to be compatible with iOS3.2.
-(void)applicationWillResignActive:(Notification *)notification{
if (self.actionSheet && self.actionSheet.visible){
NSLog(@" actionSheet is Visible");
[self.actionSheet dismissWithClickedButtonIndex:0 animated:NO];
}
}
Testing this in a simulator (iphone 3.2, iOS4), with the actionSheet visible, I click the home button, but I don't get the "ActionSheet Visible" message. However, when I open the application again and fire it again using the home button, I get an “ActionSheet Visible” message.
This indicates that for the first time the visibility property actionSheet is not set. Could there be a delay in setting the property? In fact, I put the message in a method that displays the actionSheet
[self.actionSheet showInView:self.parentViewController.tabBarController.view];
if (self.actionSheet.Visible) NsLog(@" action Sheet visible");
even here I do not receive a message. Where / when is the visible set of properties? Am I doing something fundamentally wrong while trying to fire an actionSheet? I have seen similar very good and detailed solutions for disabling alertViews in SO .... but they don't seem to cover this issue. Any help would be much appreciated.
source
share