定时器的设置
来源:互联网 发布:2002世界杯黑哨知乎 编辑:程序博客网 时间:2024/05/18 04:00
//设置定时器
- (void)setMyTimer
{
_timer = [NSTimer scheduledTimerWithTimeInterval:5.0 target:self selector:@selector(getDeviceWords) userInfo:nil repeats:YES];
[[NSRunLoop currentRunLoop] addTimer:_timer forMode:NSRunLoopCommonModes];//这段代码解决了定时器早scrollView上卡顿的问题。
}
//开启计时器
- (void)startTimer
{
//开启定时器
[_timer setFireDate:[NSDate distantPast]];
}
//停止计时器
- (void)stopTimer
{
[_timer invalidate];
_timer = nil;
}
//暂停计时器
- (void)pauseTimer
{
[_timer setFireDate:[NSDate distantFuture]];
}
//注册程序进入前台通知
[[NSNotificationCenter defaultCenter] addObserver:self selector:@selector (startTimer1) name: UIApplicationWillEnterForegroundNotification object:nil];
//注册程序进入后台通知
[[NSNotificationCenter defaultCenter] addObserver:self selector:@selector (pauseTimer1) name: UIApplicationDidEnterBackgroundNotification object:nil];
- (void)dealloc
{
//销毁计时器
[self.homePageView stopTimer];
//解除程序进入前台通知
[[NSNotificationCenter defaultCenter] removeObserver:self name: UIApplicationWillEnterForegroundNotification object:nil];
//解除程序进入后台通知
[[NSNotificationCenter defaultCenter] removeObserver:self name: UIApplicationDidEnterBackgroundNotification object:nil];
}
- S3C2440的定时器设置
- S3C2440的定时器设置
- Spring的定时器设置
- 定时器的设置
- 定时器的设置
- s3c2440中定时器的设置
- 定时器1的设置 s5pc100
- 关于定时器位置的设置
- stm32定时器的基本设置
- spring 定时器的时间设置
- STC89C52RC定时器的相关设置
- Quartz定时器的时间设置
- 定时器设置
- 定时器设置
- Spring 定时器的时间设置规则
- Spring 定时器的时间设置规则
- uboot中timer定时器的设置
- Spring Quartz定时器的时间设置
- (Leetcode)Max Consecutive Ones --- 寻找最长连接数
- android之 照相机 Camera
- 黑白图片上色算法
- STL::unordered_map之无序map
- android的相关资料
- 定时器的设置
- **JAVA**paint方法和Graphic类
- LeetCode No.70 Climbing Stairs
- C语言中strstr函数的简单实现
- 设置字体行间距
- 设计模式之——单例模式(二)
- STM32F4 LWIP UDP Demo
- 常见的进程调度算法
- HTML5移动端手机网站开发流程