定时器 NSTimer 开始、暂停、继续、停止
2016-03-04 00:00
447 查看
定时器 NSTimer
开始
暂停
继续
停止
开始
if (_timer==nil) { _timer = [NSTimer scheduledTimerWithTimeInterval:0.01 target:self selector:@selector(startFly) userInfo:nil repeats:YES]; }
暂停
if (_timer!=nil) { //定时器暂 [_timer setFireDate:[NSDate distantFuture]] }
继续
if(_timer){ //定时器继续 [_timer setFireDate:[NSDate distantPast]]; }
停止
//停止定时器,销毁定时器 if (_timer) { [_timer invalidate]; _timer = nil; }
相关文章推荐
- 停靠模式
- UIView 自带动画
- iOS-点击图片放大,再次点击返回原视图 类似查看相册的功能
- ZBrush中的PaintStop插件该怎么灵活运用
- android 为textView设置selector
- 守护进程的创建
- ORA-01000: 超出打开游标的最大数
- TypeScript Generics(泛型)
- “软件工程(C编码实践篇)”实验报告(一)
- “软件工程(C编码实践篇)”实验报告(二)
- “软件工程(C编码实践篇)”实验报告(三)
- “软件工程(C编码实践篇)”实验报告(四)
- “软件工程(C编码实践篇)”实验报告(五)
- “软件工程(C编码实践篇)”实验报告(六)
- 什么是面向对象编程
- 微信公众号定位和盈利模式
- 用什么软件可以快速制作微信视频
- UI-Navigation 和 UITabBar Controller 标题问题
- Linux 下 命令行 mail 发邮件方法
- 使用AFNetworking框架遇到的一个经典bug的解决方案