views:

258

answers:

2

I'm looking for a way, to automatically dismiss an alert view after some time or after a task is done. Is there a possibility? (or another way to show a message for some time?)

A: 

UIAlertView has a method called:

- ( void )dismissWithClickedButtonIndex: ( NSInteger )buttonIndex animated:( BOOL )animated

You can call it on your UIAlertView object to simulate a button press.
To dismiss it automatically after some time, you will need something like an NSTimer, to check if the alert view is still displayed, and in such a case, dismiss it.

Macmade
+7  A: 

You can call the -dismissWithClickedButtonIndex:animated: method to dismiss the alert view.

To dismiss it automatically, create an NSInvocation and then use -performSelector:withObject:afterDelay: to -invoke it.

KennyTM
yes this is good option... if you wanna leave the function. but if you don't wanna leave the function in execution then u can use NSRunLoop and loop until the task is done and then dismiss alert view. In such case, Macmade suggested NSTimer is okay.
MobiHunterz