我想使用微调器。但是,下面的代码不显示 微调器,我不确定为什么。如何使这项工作?顺便说一句,它正在 从我创建的提交按钮调用。
//spinner declared in .h file
UIActivityIndicatorView *aSpinner;
//throw up spinner from submit btn we created
aSpinner = [[UIActivityIndicatorView alloc] initWithActivityIndicatorStyle:
UIActivityIndicatorViewStyleWhiteLarge];
[self.view addSubview:aSpinner];
[aSpinner release];
[aSpinner startAnimating];
//send blocking request
[request startSynchronous];
//get rid of spinner when finished delegate is fired
- (void)requestFinished:(ASIHTTPRequest *)request
{
NSLog(@"REQUEST FINISHED");
[aSpinner stopAnimating];
//[aSpinner release];
}
最佳答案
如果在显示微调器后立即调用一些阻塞代码,UI 将不会更新,因为它仅在主运行循环运行时更新。如果这确实是问题的根源,那么当您注释掉 [request startSynchronous]
行进行测试时,微调器应该会出现。
解决方案是使用异步请求。委托(delegate)代码看起来您已经这样做了,但另一方面,开始调用提到了同步操作。介意解释一下吗? (还是我忽略了什么?)
关于ios - 无法让微调器出现,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/4586665/