Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How do you dismiss a UIActionSheet from the App Delegate?

I'm trying to dismiss a UIActionSheet from the app delegate so that it doesn't show again when you return from background. I've tried to dismiss the action sheet from the viewDidUnload or viewDidDisappear methods in the subclass view controller, but that doesn't seem to get called when the app backgrounds.

Therefore, I'm trying to use the app delegate to dismiss either UIActionSheet that may be showing when the app backgrounds. But I can't figure out what to call. Does anyone have a solution? Or a better idea to accomplish the same thing?

Thanks.

like image 606
Dylan Gattey Avatar asked Jun 12 '11 02:06

Dylan Gattey


2 Answers

@Dylan what you can do is you can declare the property for your uiactionsheet variable and also synthesis it.

Then in appdelegate in applicationDidBecomeActive method you can dismiss that actionsheet by calling the dismiss method by doing something like this [viewController.actionSheet dismissWithClickedButtonIndex:0 animated:NO]. Assuming that you have the reference in your appdelegate.

But if not then you can find all the UIViews shown on top of the uiwindow and then check if any of the uiviews is kind of class that is showing actionsheet. After that you can dismiss the actionsheet by doing the same as written above once you have the hold of that viewController that is showing actionsheet.

like image 187
Robin Avatar answered Oct 17 '22 17:10

Robin


try to dismiss in applicationDidBecomeActive method of appDelegate.

like image 31
Rahul Vyas Avatar answered Oct 17 '22 18:10

Rahul Vyas