gpt4 book ai didi

ios - UIActivityIndi​​catorView 未显示在 UIAlertView 上

转载 作者:行者123 更新时间:2023-11-28 20:12:38 25 4
gpt4 key购买 nike

我正在尝试添加一个带有一些信息文本的事件指示器来显示网络事件,在本例中为网络服务调用。我的警报 View 在 Web 服务调用期间正确显示,但我无法让事件指示器 View 显示在警报 View 上。

-(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];
});
});
}

有人可以帮忙吗?谢谢!

最佳答案

你试过吗?

[alert setValue:spinner forKey:@"accessoryView"];

在标准警报 View 中获取自定义内容。

关于ios - UIActivityIndi​​catorView 未显示在 UIAlertView 上,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/19571778/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com