sta*_*one 1 iphone uiprogressview ios
我在按钮单击[NSThread detachNewThreadSelector: @selector(spinBegininapp) toTarget:self withObject:nil];中显示此代码以显示后台线程正在运行的用户的活动指示器,我将此代码用于启用活动指示器
- (void)spinBegininapp
{
_activityindictor.hidden = NO;
}
Run Code Online (Sandbox Code Playgroud)
它工作正常,当我点击它显示活动指示器动画的按钮,当线程它隐藏活动指示器,但我需要显示progressView而不是活动指示器,它根据线程进展,如果线程完成,它需要完全达到进度并自我隐藏.这是可能的.
#pragma mark - Loading Progress
static float progress = 0.0f;
-(IBAction)showWithProgress:(id)sender {
progress = 0.0f;
_progressView.progress = progress;
[self performSelector:@selector(increaseProgress) withObject:nil afterDelay:0.3];
}
-(void)increaseProgress {
progress+=0.1f;
_progressView.progress = progress;
if(progress < 1.0f)
[self performSelector:@selector(increaseProgress) withObject:nil afterDelay:0.3];
else
[self performSelector:@selector(dismiss) withObject:nil afterDelay:0.2f];
}
-(void)dismiss {
[self progressCompleted];
}
Run Code Online (Sandbox Code Playgroud)
现在,无论何时何地想要显示进度,都要调用以下函数
[self showWithProgress:nil];
Run Code Online (Sandbox Code Playgroud)
进度范围介于0.0和1.0之间
1.0表示100%
| 归档时间: |
|
| 查看次数: |
19531 次 |
| 最近记录: |