我正在尝试向我的应用添加下载进度视图,虽然它在调试预览中显示,但它实际上并未显示在设备上。任何人都可以向我解释这个吗?
以下是调试和一些代码的屏幕截图:
- (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];
}
答案 0 :(得分:1)
我会猜测 - 它必须是狂野的,因为你拒绝展示你的代码 - 你打电话给updateDownloadProgress
后你正在进行同步网络。这就是问题的原因。因此,活动视图无法开始旋转将是诊断性的,真正的问题是同步网络,这是禁忌。