I am writing an iOS application and I need to display a UIAlertView with a counter. Sometimes something goes wrong when I try to add a counter to the warning center, usually when there was another warning before (not quite correct, but this is how I noticed that it does not work).
I partially resolved this error by delaying the creation of the counter. This is how I do it (warning is a member of UIAlertView):
This code is in viewDidLoad:
alert = [[[UIAlertView alloc] initWithTitle:@"Loading..." message:nil delegate:nil cancelButtonTitle:nil otherButtonTitles: nil] autorelease];
[alert show];
[self performSelector:@selector(addSpinner) withObject:nil afterDelay:0.5f];
And this is my addSpinner function:
- (void) addSpinner{
UIActivityIndicatorView *indicator2 = [[UIActivityIndicatorView alloc] initWithActivityIndicatorStyle:UIActivityIndicatorViewStyleWhiteLarge];
indicator2.center = CGPointMake(alert.bounds.size.width / 2, alert.bounds.size.height - 50);
[indicator2 startAnimating];
[alert addSubview:indicator2];
[indicator2 release];
}
, , . , , . iOS , ? - " , addSpinner"? , , ...
, - ! .