gpt4 book ai didi

ios - 如何使 NSTimer 失效?

转载 作者:行者123 更新时间:2023-11-29 11:02:33 30 4
gpt4 key购买 nike

self.timerProgress=[NSTimer scheduledTimerWithTimeInterval:50.0 target:self selector:@selector(stopProgressView) userInfo:nil repeats:NO];

-(void)stopProgressView
{
if ([self.timerProgress isValid]) {
[self.timerProgress invalidate];
self.timerProgress=nil;
}

}

当我试图使 NSTimer 对象无效时单击按钮

-(void)cancelTimer
{
if ([self.timerProgress isValid]) {
[self.timerProgress invalidate];
self.timerProgress=nil;
}
}

它不会失效。它在间隔 50 后调用一次 stopProgressView。如何解决这个问题?

最佳答案

- (IBAction)stopTimer {
if ([timerProgress isValid]) {
[timerProgress invalidate];
}
}

不要使用 self.timerProgress 只使用 timerProgress

关于ios - 如何使 NSTimer 失效?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/15217156/

30 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com