Ios 进度视图循环

Ios 进度视图循环,ios,objective-c,uiprogressview,Ios,Objective C,Uiprogressview,我希望这个进度视图在完成时基本上“重置” 尝试将计数重置为0,但每次重置计时器都会越来越快 h m -(void)updateUI:(NSTimer*)计时器 { 静态整数计数=0;计数++; 如果(count您需要在将计时器设置为nil之前使其无效。到目前为止,您对invalidate的调用是不可操作的。这意味着您不断添加越来越多的活动计时器。因此基本上其他{//invalidate before nil[self.myTimer invalidate];self.myTimer=nil;//

我希望这个进度视图在完成时基本上“重置”

尝试将计数重置为0,但每次重置计时器都会越来越快

h

m

-(void)updateUI:(NSTimer*)计时器
{
静态整数计数=0;计数++;

如果(count您需要在将计时器设置为
nil
之前使其无效。到目前为止,您对
invalidate
的调用是不可操作的。这意味着您不断添加越来越多的活动计时器。

因此基本上其他{//invalidate before nil[self.myTimer invalidate];self.myTimer=nil;//下一个问题的shot方法count=0;哈哈,哇哦。没有看到即将到来的伙伴。这很有效!非常感谢!这个问题让我质疑我作为dev.JK的未来。很高兴我能提供帮助。别忘了接受一个解决你问题的答案。
@property (nonatomic, strong) NSTimer *myTimer;
@property (weak, nonatomic) IBOutlet UILabel *progressLabel;
- (void)updateUI:(NSTimer *)timer
{
    static int count = 0; count++;

    if (count <=100)
    {
        self.progressView.progress = (float)count/100.0f;
    }
    else
    {
        self.myTimer = nil;
        [self.myTimer invalidate];
        // shoot method for next question
        count = 0;

    self.progressView = [[UIProgressView alloc] initWithProgressViewStyle:UIProgressViewStyleDefault];

    self.progressView.center = self.view.center;
    [self.view addSubview:self.progressView];

    self.myTimer = [NSTimer scheduledTimerWithTimeInterval:3 target:self selector:@selector(updateUI:) userInfo:nil repeats:true];
    }
}