zhufeng1994

   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];

 希望对帮助!!!

 

 

   

   

分类:

技术点:

相关文章:

  • 2021-11-30
  • 2022-12-23
  • 2021-06-14
  • 2022-01-24
  • 2022-12-23
  • 2021-11-21
  • 2021-11-07
  • 2021-12-16
猜你喜欢
  • 2021-11-30
  • 2021-11-30
  • 2021-11-30
  • 2021-10-23
  • 2022-12-23
  • 2022-12-23
相关资源
相似解决方案