开发者

display text, then let it disappear after a minute

I'd like to display a short warning message in an existing UILabel and then have it automatically disappear after a minute or so without havi开发者_如何学Gong to pause the app (as in doing a loop or similar).

What's the best approach ?


Use an NSTimer:

NSTimer* timer = [NSTimer scheduledTimerWithTimeInterval:60 target:self selector:@selector(hideLabel) userInfo:nil repeats:NO]; 

And have a method hideLabel that hides the label, with [myLabel setHidden:YES]; or something like that.


I wrote this myself. It's pretty simple and it's probably what you are looking for. Popup any UIView instance on top or bottom then disappear after a few seconds.

https://github.com/SaKKo/SKTipAlertView

Hope you find it useful. cheers,


Use UIAlertView (with no buttons) for popping up something interesting.

UIAlertView *alertView = [[UIAlertView alloc] initWithTitle:@"Title"
           message:@""
             delegate:self
          cancelButtonTitle:@""
          otherButtonTitles:nil];
[alertView show];
[alertView release];

Create an method for dismissing alertView after (say 2 seconds)

[self performSelector:@selector(byeAlertView:) withObject:alertView afterDelay:2];

Method for dismissing it...

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

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜