Display the text, then let it disappear in a minute

I want to display a short warning message in an existing UILabel , and then automatically disappear after a minute or so, without having to pause the application (as in a loop or similar).

What is the best approach?

+4
source share
3 answers

Use NSTimer:

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

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

+4
source

I wrote it myself. This is pretty simple, and this is probably what you are looking for. The pop-up instance of the UIView above or below disappears after a few seconds.

https://github.com/SaKKo/SKTipAlertView

I hope you find this helpful. greetings

+1
source

Use a UIAlertView (without buttons) for something interesting to appear.

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

Create an alertView rejection method after (say 2 seconds)

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

The method of rejecting it ...

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

All Articles