[英]iOS Camera Countdown Timer
当用户点击“拍照”按钮时,我正在寻找最简洁的方法让倒数计时器触发。 有没有简单的方法来做到这一点?
我想到的一个解决方案就是让每一秒都有一个标签更新,但有没有办法让它像Photobooth一样工作?
此外,在即将拍摄照片之前的最后一秒,我希望在拍摄图像时能够短暂显示图像。 我怎么能这样做?
任何帮助都会很棒,谢谢!
- (IBAction)takePicture:(id)sender {
theTimer = [NSTimer scheduledTimerWithTimeInterval:0.5 target:self selector:@selector(updateLabel:) userInfo:nil repeats:NO];
}
- (void)updateLabel:(NSTimer *)timer {
_timeLabel.text = [NSString stringWithFormat:@"%d", time];
time = time - 1;
if (time == 0) {
[theTimer invalidate];
[_timeLabel performSelector:@selector(setText:) withObject:@"Photo taken!" afterDelay:1.0];
//Code for image shown at last second
} else {
theTimer = [NSTimer scheduledTimerWithTimeInterval:1.0 target:self selector:@selector(updateLabel:) userInfo:nil repeats:NO];
}
}
希望这可以帮助 ;)
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.