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?
sleep() blocks the main thread, so no UI updates will happen. You need to use NSTimer or something similar.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.