开发者

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

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

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜