ActivityView未显示
问题描述:
我正在尝试向我的应用程序添加下载进度视图,并且它在调试预览中显示时并未实际显示在设备上。任何人都可以向我解释这个吗?ActivityView未显示
这里是调试的截图和一些代码:
- (void)updateDownloadProgressWithBatchIndex:(int)index contentName:(NSString *)name
{
CGSize size = self.view.bounds.size;
_loadingView = [[UIView alloc] initWithFrame:CGRectMake(75, 155, 170, 170)];
_loadingView.backgroundColor = [UIColor blackColor];
_loadingView.clipsToBounds = YES;
_loadingView.layer.cornerRadius = 10.0;
[_loadingView setCenter:CGPointMake(size.width/2, size.height/2)];
_activityView = [[UIActivityIndicatorView alloc] initWithActivityIndicatorStyle:UIActivityIndicatorViewStyleWhite];
_activityView.frame = CGRectMake(65, 40, _activityView.bounds.size.width, _activityView.bounds.size.height);
_activityView.hidden = NO;
[_activityView setCenter:CGPointMake(size.width/2, size.height/2)];
[_loadingView addSubview:_activityView];
_loadingLabel = [[UILabel alloc] initWithFrame:CGRectMake(20, 115, 130, 22)];
_loadingLabel.backgroundColor = [UIColor clearColor];
_loadingLabel.textColor = [UIColor whiteColor];
_loadingLabel.adjustsFontSizeToFitWidth = YES;
_loadingLabel.textAlignment = UITextAlignmentCenter;
_loadingLabel.text = [NSString stringWithFormat:@"Batch %i downloading...", index];
[_loadingView addSubview:_loadingLabel];
[self.view addSubview:_loadingView];
_loadingView.hidden = NO;
UIView *v = self.view;
[_activityView startAnimating];
}
答
我要带胡乱猜测 - 它必须是野生的,因为你拒绝出示你的代码 - 在拨打updateDownloadProgress
后,您正在进行同步联网。这是问题的原因。因此,活动视图无法开始旋转将是诊断问题,因此问题是同步网络,这是一个禁忌。
+0
对不起所有的误解。我认为所说的话引发了一些想法。感谢您的帮助。 – linuxer
'updateDownloadProgressWithBatchIndex'是如何被调用的? – matt
它在下载开始时从相同类中的方法调用,并且该类是视图控制器。 – linuxer
这不是我要问的。我要求你_显示code_。如果该方法继续进行更多工作,活动视图可能永远不会出现。这不是你想要弄清楚的吗? – matt