[英]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.