开发者

how to make a UIAlertView to hide automatically without User Interaction?

开发者 https://www.devze.com 2023-04-09 06:00 出处:网络
When the focus in a particluar rect of the screen, it ne开发者_如何学JAVAed to show up a message and need to hide automatically . Whether alertview will be flexible or any other way is there to implem

When the focus in a particluar rect of the screen , it ne开发者_如何学JAVAed to show up a message and need to hide automatically . Whether alertview will be flexible or any other way is there to implement the stuffs in iPhone and iPad .


You can use timer to close alert after some time, for example:

[[NSTimer scheduledTimerWithTimeInterval:2 
                                 target:self 
                                 selector:@selector(closeAlert:) 
                                 userInfo:nil 
                                 repeats:NO] retain];

For more information look here: NSTimer Class Reference


You can dismiss the alert after displaying for some seconds. Something like this : (Dismiss after 5 seconds)

 UIAlertView *yourAlert = [[UIAlertView alloc]initWithTitle:@"title" message:@"message" delegate:nil cancelButtonTitle:nil otherButtonTitles:nil]; 
        [yourAlert show];
        [self performSelector:@selector(dismiss:) yourAlert afterDelay:5.0];



-(void)dismiss:(UIAlertView*)alert
{
    [alert dismissWithClickedButtonIndex:0 animated:YES];
}
0

精彩评论

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