开发者

Is there a way to dismiss an alertview automatically after some time?

开发者 https://www.devze.com 2022-12-29 01:27 出处:网络
I\'m looking for a way, to automatically dismiss an alert view after some time or after a task is done.

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开发者_如何学JAVA show a message for some time?)


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.


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.

0

精彩评论

暂无评论...
验证码 换一张
取 消