首页 > 移动平台 > 详细

ios 之定时器的使用的技巧(结合runloop)使用

时间:2016-05-13 10:09:38      阅读:243      评论:0      收藏:0      [点我收藏+]

   1.在项目中要使用到定时器,但是遇到了问题就是无法关闭定时器的,在网上找了资料才发生了原来定时器是要结合runloop的使用一起来的呀,不然是无法关闭定时器的使用的

    self.timer1 = [NSTimer scheduledTimerWithTimeInterval:1.0 target:self selector:@selector(mythod1) userInfo:nil repeats:YES];

        //将定时器加入到当前的runloop里面

        [[NSRunLoop currentRunLoop]addTimer:self.timer1 forMode:NSRunLoopCommonModes];

      关闭定时器: [self.timer1 setFireDate:[NSDate distantFuture]];

  定时器失效: [self.timer1 invalidate];

 希望对帮助!!!

 

 

   

   

ios 之定时器的使用的技巧(结合runloop)使用

原文:http://www.cnblogs.com/zhufeng1994/p/5486099.html

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