/** 添加定时器 */
@property (nonatomic, strong) NSTimer *timer;

- (void)addTimer
{
// 2秒后,自己 调用nextImage方法 nil 一直循环这个定时器
self.timer = [NSTimer scheduledTimerWithTimeInterval:2.0 target:self selector:@selector(nextImage) userInfo:nil repeats:YES];
// 给定时器添加优先级
[[NSRunLoop currentRunLoop] addTimer:self.timer forMode:NSRunLoopCommonModes];
}
/** 移除定时器 */
- (void)removeTimer
{ // 定时器一旦被停止,不会重新开始,要被移除。
[self.timer invalidate];
self.timer = nil;
}

posted on 2015-09-15 18:36  xiao孛  阅读(150)  评论(0编辑  收藏  举报