首页 > 其他 > 详细

(3) 计时器NSTimer

时间:2015-12-18 21:02:27      阅读:168      评论:0      收藏:0      [点我收藏+]

 (3) 计时器NSTimer

+ (NSTimer *)scheduledTimerWithTimeInterval:(NSTimeInterval)ti target:(id)aTarget selector:(SEL)aSelector userInfo:(id)userInfo repeats:(BOOL)yesOrNo;

- (NSDate *)fireDate; 获得计时器开始时间

- (void)invalidate; 关闭计时器

 

NSTimer

//timerWithTimeInterval创建的timer需要添加到主线程中才能执行

self.timer = [NSTimer timerWithTimeInterval:1.5 target:self selector:@selector(nextImage) userInfo:nil repeats:YES];

[[NSRunLoop mainRunLoop] addTimer:self.timer forMode:NSRunLoopCommonModes];

 //scheduledTimerWithTimeInterval方法创建的无需添加到主线程即可执行

self.timer = [NSTimer scheduledTimerWithTimeInterval:1.5 target:self 
selector:@selector(nextImage) userInfo:nil repeats:YES];

 //停止定时器

[self.timer invalidate];

self.timer = nil;

(3) 计时器NSTimer

原文:http://www.cnblogs.com/linxiu-0925/p/5058179.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!