码迷,mamicode.com
首页 > 其他好文 > 详细

定时器 注意事项

时间:2015-04-18 23:47:55      阅读:156      评论:0      收藏:0      [点我收藏+]

标签:

/**

 *  开始定时器

 */

-(void)addTimer

{

    NSTimer * timer = [NSTimer scheduledTimerWithTimeInterval:2.0 target:self selector:@selector(nextPage) userInfo:nil repeats:YES];

//    这样 timer就不是在主线程中了 一旦主线程有时间 就会 执行这个操作

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

    

    self.timer = timer;

}

/**

 *  移除定时器

 */

-(void)removeTimer

{

    [self.timer invalidate];

    self.timer = nil;

}


定时器 注意事项

标签:

原文地址:http://blog.csdn.net/guoyule2010/article/details/45117821

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!