Reputation: 305
I don't understand where I lay an egg. I need to update progress of progreesView. I create UIProgressView in IB and change only color. I have property and next code
@property (weak, nonatomic) IBOutlet UIProgressView *progressView;
property connect to outlet in IB
- (void)viewDidLoad
{
[super viewDidLoad];
self.view.backgroundColor = [UIColor colorWithPatternImage:[UIImage imageNamed:@"DefaultSS.png"]];
}
- (void) viewDidAppear:(BOOL)animated
{
[self connectToServer];
}
- (void) connectToServer
{
//some code...
sleep(2);
[self.progressView setProgress:0.2 animated:YES];
sleep(1);
[self.progressView setProgress:0.4 animated:YES];
sleep(1);
[self.progressView setProgress:0.7 animated:YES];
sleep(1);
[self.progressView setProgress:1.0 animated:YES];
sleep(1);
//some code...
}
Sleep work well, but progress of UIProgressView don't change with time. Where I mistaked?
Upvotes: 2
Views: 684
Reputation: 7703
sleep() blocks the main thread, so no UI updates will happen. You need to use NSTimer or something similar.
Upvotes: 4