I want to know if it is possible for an AlertView to time out if it has been visible on the screen for a certain period of time without receiving any acknowledgement from the user, and if so, how? Is there a way for the AlertView object be linked with an NSTimer object?
My basic AlertView code is the following:
- (IBAction)showMessage:(id)sender {
UIAlertView *message = [[UIAlertView alloc] initWithTitle:@"Hello World!"
message:@"This is your first UIAlertview message."
delegate:nil
cancelButtonTitle:@"OK"
otherButtonTitles:nil];
[message show];
}
This is how I implemented in one of my apps
Inside the @interface declare your objects so you can keep track of them and add the if required
In your code where you need to launch the alert add the following
Somewhere in your code add next function to dismiss the alert and invalidate the NSTimer
Also remember to invalidate the timer if a button is touched.
It may need some tweaks for your requirements.