---------------------------------------NSTimer的用法-------------------------------------------------
wSelf.timeFlag = 60;
wSelf.timer = [NSTimerscheduledTimerWithTimeInterval:1.0target:selfselector:@selector(timerUp:) userInfo:nilrepeats:YES];
[[NSRunLoopcurrentRunLoop]addTimer:wSelf.timerforMode:NSRunLoopCommonModes];//有了这句,表格滚动的时候,定时器也不会停止了。
wSelf.sendCode.userInteractionEnabled = NO;
- (void)timerUp:(NSTimer*)timer{
self.timeFlag -- ;
if (self.timeFlag <= 0) {
if(self.timer && [self.timer isValid]){// 没用的时候要记得销毁timer
[self.timer invalidate];
self.timer = nil;
}
self.sendCode.userInteractionEnabled = YES;
[self.sendCodesetTitle:NSLocalizedString(@"获取验证码", nil) forState:UIControlStateNormal];
}else{
self.sendCode.userInteractionEnabled = NO;
[self.sendCodesetTitle:[NSStringstringWithFormat:@"%d s",self.timeFlag] forState:UIControlStateNormal];
}
}
相关推荐
简单的nstimer时间计算器,上面有暂停,清零等简单的功能,免费下载
详细讲解CADisplayLink和NSTimer的区别。
ios计时器NSTimer的使用 倒计时10秒,计时器 /* NSTimer scheduledTimerWithTimeInterval
ios NSTimer应用demo 。iphone6.1 测试通过。具体demo截图和说明在:http://blog.csdn.net/donny_zhang
MKImpulse是一个用来代替系统NSTimer的高精度脉冲器 系统的NSTimer是添加到Runloop中的, 在系统繁忙时会造成偏差, 时间越长, 偏差越大 而MKImpulse是基于GCD编写的脉冲器, 精度由CPU时钟进行计算, 误差基本可以...
NSTimer-Blocks, 在NSTimer上提供块功能,简单分类 自述文件NSTimer上非常简单的类别,它可以使用块。工作原理我认为如果你使用的是一个块,你可以能不需要将任何用户指定的对象传递到计时器。 你只要从街区里得到你...
是一个关于NSTimer类的小计时器,主要是为了对比两个类方法创建定时器的区别,以及它们会受到滚动事件的影响,该如何解决这个问题
详细介绍CADisplayLink,CADisplayLink和NSTimer的区别。
NStimer 定时器 iOS 倒计时 objective-c
关于定时器在tableview上的复用问题
详细的NSTimer类的使用 文档说明 是开发的很好的帮助文档
模仿腾讯新闻图片频道的图片浏览的幻灯片效果.
常见NSTimer的消毁方法,用一种优雅的方式销毁NSTimer
iOS 中的 NSTimer.pdf
IOS应用源码——nstimer.zip
我们都知道NSTimer采用target-action的方式,通常target又是类本身,我们为了方便又把NSTimer声明为属性变量,这样就难免会造成循环引用(需要反复执行计时任务时,如果是单次的任务就不会造成循环引用)。...
Swift:UIProgressView+NSTimer+UIstepper
定时器
IOS 中NSTimer定时器的使用 NSTimery 定时器,主要用于进行定时执行指定方法,常用场景如:获取验证码的按钮倒计时;图片轮播定时。 1 使用注意事项: 1.1 倒计时时间间隔(时间单位是秒) 1.2 指定的执行方法 1.3...
NSTimer alternative that doesn't retain the target (请叫我汪二 出品).zip,NSTimer alternative that doesn't retain the target