我不明白我在哪里下蛋。我需要更新progreesView 的进度。我在 IB 中创建 UIProgressView 并仅更改颜色。我有财产和下一个代码
@property (weak, nonatomic) IBOutlet UIProgressView *progressView;
属性连接到 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...
}
睡眠效果很好,但 UIProgressView 的进度不会随时间变化。我哪里弄错了?