Я пытаюсь добавить индикатор активности с некоторым информационным текстом, чтобы показать активность сети, в данном случае, вызов веб-службы. Мое предупреждение отображается правильно во время вызова веб-службы, но я не могу отобразить представление индикатора активности в представлении предупреждения.UIActivityIndicatorView не отображается на UIAlertView
-(void)viewDidAppear:(BOOL)animated{
[super viewDidAppear:animated];
CGRect screenRect = [[UIScreen mainScreen] bounds];
NSString *loadingText = [NSString stringWithFormat:@"Loading %@ gauges...", [self stateIdentifier]];
UIAlertView *alert = [[UIAlertView alloc] initWithTitle:nil message:loadingText delegate:self cancelButtonTitle: nil otherButtonTitles: nil];
alert.frame = CGRectMake(0,0,300,200);
UIActivityIndicatorView *spinner = [[UIActivityIndicatorView alloc]initWithFrame:
CGRectMake(roundf((screenRect.size.width - 50)/2),
roundf((screenRect.size.height - 50)/2),50,50)];
spinner.color = [UIColor blackColor];
[alert addSubview:spinner];
[self.tableView bringSubviewToFront:alert];
spinner.hidesWhenStopped = YES;
spinner.hidden = NO;
[spinner startAnimating];
[alert show];
dispatch_async(dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_HIGH, 0), ^{
stateGauges = [[GaugeList alloc] initWithStateIdentifier:stateIdentifier andType:nil];
dispatch_async(dispatch_get_main_queue(), ^{
[self.tableView reloadData];
[spinner stopAnimating];
[alert dismissWithClickedButtonIndex:-1 animated:YES];
});
});
}
Может ли кто-нибудь помочь? Благодаря!
'UIAlertView' не поддерживает добавление подвидов, особенно под прошивкой 7. – rmaddy
Так , что может быть решением? Специально для поддержки iOS7? – Pheepster
Не используйте 'UIAlertView'. Посмотрите на другие решения, такие как https://github.com/jdg/MBProgressHUD?source=cc – rmaddy