如何在 NSTimer 的标签中显示秒数?
imageVC.h
@property (weak, nonatomic) IBOutlet UILabel *timeLabel;
imageVC.m
-(void)viewDidAppear:(BOOL)animated
{
[super viewDidAppear:animated];
imageViewController *pickerView = [[imageViewController alloc] init];
[NSTimer scheduledTimerWithTimeInterval:10
target:self
selector:@selector(timeout)
userInfo:nil
repeats:NO];
}];
}
}
如有任何帮助,我们将不胜感激。
谢谢
最佳答案
尝试将超时值设置为您想要的最大值。
timer = [NSTimer scheduledTimerWithTimeInterval:1 target:self selector:@selector(timeout) userInfo:nil repeats:YES];
-(void) timeout {
if (timeCount==0) {
[timer invalidate];
} else {
timeCount = timeCount-1;
timeLabel.text = [NSString stringWithFormat:@"%d",timeCount];
}
}
关于ios - 在从 UIPickerView 选择的 NSTimer 的 UILabel 中显示秒数,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/31566613/