Im displaying an activity indicator with an Alert View using:
UIAlertView *Alert= [[UIAlertView alloc] initWithTitle:@"Loading"
message:@"\n"
delegate:self
cancelButtonTitle:nil
otherButtonTitles:nil];
UIActivityIndicatorView *spinner = [[UIActivityIndicatorView alloc] initWithActivityIndicatorStyle:UIActivityIndicatorViewStyleWhiteLarge];
spinner.center = CGPointMake(139.5, 75.5);
[Alert addSubview:spinner];
[spinner startAnimating];
[Alert show];
[Alert dismissWithClickedButtonIndex:0 animated:YES];
The only thing is it disappears off the screen real quick, I would like to specify how long the alert stays on screen for, say two seconds, rather than the nano second its displayed for now. Im unsure how to go about/implement this, would I use some sort of NSTimer, if so some advice how to implement this would be very much appreciated. Thanks.
Here is an example of how I would go about solving the problem using
NSTimerandNSInvocation. I have not tested it, so might have some trouble with it.I still do not think this is the best answer to the question though. In most cases you should use the indicator until the work to be done is complete, not based on a time, especially not a time that can change or dependent on other factors.
So the correct answer would be wait until the work is done and at that point dismiss the
UIAlertView.