Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

UIAlertView disappears when app goes to background and come back to foreground

I am developing an iPhone application (iPhone with multi tasking support) in which I am displaying UIAlertView on error. When UIAlertView is about to get display my app is sent to background. Now, if I try to get my app in the foreground, UIAlertView gets displayed for a moment and gets dismissed automatically even if I don't call dismiss/click on any button.

Does anyone knows what the problem is?

Thanks and Regards, Deepa

like image 772
spd Avatar asked Dec 09 '10 11:12

spd


2 Answers

When you add an alert view, it is added on top of the view of the current viewcontroller and while coming back to foreground , sometimes the view is reloaded from the xib and all the contents are refreshed. I suggest you to maintain a state variable in controller which calls the alertView again when coming back to foreground.

like image 67
Rajat Talwar Avatar answered Oct 04 '22 15:10

Rajat Talwar


Rajact answer is good if by 'call' means the next

[theViewWhenYouAddedIt bringSubviewToFront:theViewWhenYouAddedIt.theAlert];

This worked for me I hope this helps someone

like image 26
Oscar Avatar answered Oct 04 '22 17:10

Oscar