首页 > 其他 > 详细

定时器 注意事项

时间:2015-04-18 23:47:03      阅读:294      评论: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
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!