首页 > 其他 > 详细

NSTimer

时间:2020-04-07 09:15:14      阅读:59      评论:0      收藏:0      [点我收藏+]

注意事项:NSTimer是一次性的,要么持续工作,一旦停止工作就无法再次使用

    // 返回一个自动开启任务的定时器

    self.timer = [NSTimer scheduledTimerWithTimeInterval:2.0 target:self selector:@selector(nextPage:) userInfo:@"123" repeats:YES];

    

    // NSDefaultRunLoopMode(默认) : 同一时间只能处理一个任务

    // NSRunLoopCommonModes(公用) : 可以分配一定的时间处理其他任务

    

    // 作用:修改timer在runloop中的模式为NSRunLoopCommonModes.

    // 目的:不管主线程在做什么操作都会分配一定的时间处理timer

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

 

NSTimer

原文:https://www.cnblogs.com/wwjwb/p/12650726.html

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