Use a UIAlertView with nil title and nil buttons, then dismiss it when desired. Here's how I did this:
Create an instance variable for the alert view in your .h file:
@interface StatusMessageController : UIViewController {
UIAlertView *statusAlert;
}
In your .m file, create a method to show the alert view and start a timer, and another to handle when the timer expires to dismiss the alert:
- (void)showStatus:(NSString *)message timeout:(double)timeout {
statusAlert = [[UIAlertView alloc] initWithTitle:nil
message:message
delegate:nil
cancelButtonTitle:nil
otherButtonTitles:nil];
[statusAlert show];
[NSTimer scheduledTimerWithTimeInterval:timeout
target:self
selector:@selector(timerExpired:)
userInfo:nil
repeats:NO];
}
- (void)timerExpired:(NSTimer *)timer {
[statusAlert dismissWithClickedButtonIndex:0 animated:YES];
}
Whenever you want to show the status message, invoke it:
[self showStatus:@"Computing" timeout:4.5];
At any time, you can also dismiss the alert with:
[statusAlert dismissWithClickedButtonIndex:0 animated:YES];
You can also change the message on-the-fly with new status:
statusAlert.message = @"Looking up user";