Search code examples
ioshiddenprogressuiactivityindicatorview

ActivityView not showing


I am trying to add a download progress view to my app, and while it shows in the debug preview, it does not actually show on the device. Can anyone explain this to me?

Here is a screenshot of the debug and some code:

enter image description here

- (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];
}

Solution

  • I'm going to take a wild guess - it has to be wild, because you refuse to show your code - that you are proceeding to synchronous networking after you call updateDownloadProgress. That's the cause of the issue. The inability of the activity view to start spinning would thus be diagnostic, the real issue being the synchronous networking, which is a no-no.