ActivityView 不显示

ActivityView not showing

我正在尝试向我的应用程序添加下载进度视图,虽然它显示在调试预览中,但实际上并没有显示在设备上。谁能给我解释一下?

这是调试的屏幕截图和一些代码:

- (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 之后你将继续进行同步网络。这就是问题的原因。因此,activity 视图无法开始旋转将是诊断性的,真正的 问题是同步网络,这是一个禁忌。