0

I'm using iOS 6's Social API to send tweets, and I want to have an progress view. Following is the message to show.

    [self.progressView addStatus:@"Posting to Twitter"];

Since my App would possibly send messages to multiple destinations at the same time, I'd like to display all processing status on the progress view. So once a new message is add to the progress view, I'll build a subview and then add it to the main progress view.

UIView *containerView = [[UIView alloc] init];

UIActivityIndicatorView *weiboIndicator = [[UIActivityIndicatorView alloc] initWithActivityIndicatorStyle:UIActivityIndicatorViewStyleWhite];
weiboIndicator.tag = tag + 1;
[weiboIndicator setFrame: CGRectMake(10, 20, weiboIndicator.frame.size.width, weiboIndicator.frame.size.height)];

[containerView addSubview:weiboIndicator];
[weiboIndicator startAnimating];

UILabel *label = [[UILabel alloc] initWithFrame:CGRectMake(34, 23, 40, 60)];
label.tag = tag;
label.text = status;
label.backgroundColor = [UIColor clearColor];
label.textColor = [UIColor whiteColor];
label.font = [UIFont boldSystemFontOfSize:12];
label.adjustsFontSizeToFitWidth = YES;
label.hidden = NO;
[label sizeToFit];

[containerView addSubview:label];

It's a very simple UIView. Then I add it to the main progress view

dispatch_async(dispatch_get_main_queue(), ^{
        [[ParallelProgressView sharedView] addSubview:progressVivew];

        //change height to accommodate new progress view
        [[ParallelProgressView sharedView] setFrame:CGRectMake(bounds.size.width / 4, bounds.size.height / 4, bounds.size.width / 2, (index + 1) * 60 + 40 )];
        //[[ParallelProgressView sharedView] setNeedsDisplay];
    });

the problem is the activity indicator shows immediately, but not the label

enter image description here

the indicator is animating, and height of the view has changed. But the label doesn't shows until a short period later. enter image description here

fengd
  • 7,551
  • 3
  • 41
  • 44

0 Answers0