gpt4 book ai didi

ios - 调用 Web 服务后 UIActivityIndi​​catorview 不显示

转载 作者:行者123 更新时间:2023-11-28 22:19:14 25 4
gpt4 key购买 nike

在我的应用程序中,我需要在等待来自 Web 服务的响应时显示一个 UIActivityIndi​​cator。我正在使用以下代码:

  UIView *loadView = [[UIView alloc] initWithFrame:self.view.bounds];
loadView.backgroundColor = [UIColor colorWithWhite:0.0 alpha:0.5];

//UIActivityIndicatorView *activityView = [[UIActivityIndicatorView alloc] init];
//[second.loadingView addSubview:activityView];
//activityView.center = second.loadingView.center;

//[second.view addSubview:second.loadingView];


UIActivityIndicatorView *activity = [[UIActivityIndicatorView alloc] initWithActivityIndicatorStyle:UIActivityIndicatorViewStyleGray];
[loadView addSubview:activity];

activity.center = loadView.center;
[self.view addSubview:loadView];
[self.view bringSubviewToFront:loadView];
activity.hidesWhenStopped = YES;
[activity setHidden:NO];

[activity startAnimating];
// calling My web service
[self callRegisterWebService:self.userFname lastName:self.userLName email:self.userEmail];

[activity stopAnimating];
[loadView setHidden:YES];

但是,指标没有显示..!!我做错了什么??

最佳答案

您可能正在等待主线程上的 http 响应。尝试使用 dispatch_async 函数实现注册,如下所示:

[activity startAnimating];
// calling My web service
dispatch_async(dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0), ^{
[self callRegisterWebService:self.userFname lastName:self.userLName email:self.userEmail];
[activity stopAnimating];
});

关于ios - 调用 Web 服务后 UIActivityIndi​​catorview 不显示,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/20825292/

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