iOS中两种定时器

频率比较高  CADisplayLink
相隔时间较长 NSTimer

注意事项:当前线程正在处理其他事件时,定时器不会执行。可以设置线程的优先级

代码如下
self.timer = [NSTimer scheduledTimerWithTimeInterval:2.0 target:self selector:@selector(nextImage) userInfo:nil repeats:YES];
[[NSRunLoop currentRunLoop] addTimer:self.timer forMode:NSRunLoopCommonModes];

猜你喜欢

转载自invictus-fang.iteye.com/blog/2145755