'타이머'에 해당되는 글 1건

  1. 2012.06.01 메인 runloop 쓰레드에 타이머 동작 시키기
영삼이의 IT정보2012. 6. 1. 16:25

일반적으로 타이머를 동작시키면 UI 작동중에는 동작이 되질 않는다.


스크롤중이거나 버튼 터치시.. 등등 UI가 먼저 우선 순위인 것이다..


하지만 메인 runloop에 동작시키면 UI보다 우선순위가 될 수 있다..


다음처럼 하면 된다..



 self.timer = [NSTimer timerWithTimeInterval:0.5 target:self selector:@selector(countDown)

                                                        userInfo:nil repeats:YES];

 [[NSRunLoop mainRunLoopaddTimer:self.timer forMode:NSRunLoopCommonModes];

Posted by 다오나무