가능한 중복 :
UIScrollView pauses NSTimer until scrolling finishes있는 ScrollView 스레드 타이머 아이폰
는 내가있는 ScrollView 현재까지 카운트 다운을 표시하는 라벨이 있습니다. 카운트 다운이 작동하지만 스크롤 뷰를 위아래로 드래그 할 때마다 카운트 다운이 중단되었지만 손가락을 뗀 후에 다시 작동하기 시작했습니다. muti-threading과 관련이 있다는 것을 알고 있습니다. 여기 내 코드는
-(void) viewdidload
{
timer = [NSTimer scheduledTimerWithTimeInterval:0 target:self selector:@selector(updateLabel) userInfo:nil repeats:YES];
}
-(void)updateLabel {
NSCalendar *calender = [[NSCalendar alloc] initWithCalendarIdentifier:NSGregorianCalendar];
NSDateComponents *countdown = [calender
components:(NSDayCalendarUnit | NSHourCalendarUnit | NSMinuteCalendarUnit | NSSecondCalendarUnit)
fromDate:[NSDate date]
toDate:destDate
options:0];
timerCountDown.text = [NSString stringWithFormat:@"%dday %dh %dm %ds", [countdown day],[countdown hour],[countdown minute],[countdown second]];
}
시도했지만 작동하지 않았다 : ( – kevin
편집 된 답변 확인 – Ilanchezhian
나는 scrollviewdelegate를 구현하지 않았다 – kevin