1.时间控制器 但是需要注意只能在主线程中使用[NSTimer scheduledTimerWithTimeInterval:1 target:self selector:@selector(logBtnClick) userInfo:nil repeats:YES];2.延迟调用[self pe....
分类:
其他好文 时间:
2015-06-24 09:19:08
阅读次数:
136
最近在使用selector时经常思考的问题,
给UIButton 添加点击事件,可以在selector后加“:”将button作为参数传入方法中,
今天用
[NSTimer
scheduledTimerWithTimeInterval:1
target:self
selector:@selector(rotateAction:)
userInfo:nil
repeats:NO];
...
分类:
移动开发 时间:
2015-06-21 18:38:07
阅读次数:
145
计时器可以指定绝对的日期和时间,以便到时执行任务也可以指定执行的任务的相对延迟时间,还可以重复运行任务。计时器要和runloop相关联,运行循环到时候会触发任务。虾米昂这个方法可以创建并预先安排到当前运行循环中:+ (NSTimer *)scheduledTimerWithTimeInterva.....
分类:
其他好文 时间:
2015-06-20 15:33:02
阅读次数:
232
可以有两个办法让NSURLConnection在子线程中运行,即将NSURLConnection加入到run loop或者NSOperationQueue中去运行。前面提到可以将NSTimer手动加入NSRunLoop,Cocoa库也为其它一些类提供了可以手动加入NSRunLoop的方法,这些类有N...
分类:
编程语言 时间:
2015-06-19 18:06:19
阅读次数:
175
创建一个 Timer+scheduledTimerWithTimeInterval: invocation: repeats:+ (NSTimer *)scheduledTimerWithTimeInterval:(NSTimeInterval)ti invocation:(NSInvocatio....
分类:
其他好文 时间:
2015-06-15 23:27:04
阅读次数:
175
self.timerSchedule = [NSTimer scheduledTimerWithTimeInterval:0.2 target:self selector:@selector(spinPicker) userInfo:nil repeats:YES];该类函数将返回一个NSTimer...
分类:
其他好文 时间:
2015-06-11 18:35:25
阅读次数:
117
1,暂停:pauseStart = [[NSDate dateWithTimeIntervalSinceNow:0] retain]; previousFireDate = [[timer fireDate] retain]; [timer setFireDate:[NSDate dis...
分类:
其他好文 时间:
2015-06-09 23:18:31
阅读次数:
124
NSTimer作为一个常用的类,却有一个最大的弊病,就是会强引用target,造成调用timer非常麻烦,稍有不慎就造成内存泄漏。
以下就是为解决这个问题做的封装。
直接上代码:
#import
@interface LZLTimer :
NSObject
-(void)startTimerInterval:(NSTimeInterval)ti target...
分类:
其他好文 时间:
2015-06-09 17:11:03
阅读次数:
150
[NSTimer scheduledTimerWithTimeInterval:1.0 target:self selector:@selector(timerFireMethod:) userInfo:nil repeats:YES];- (void)timerFireMethod:(NSTime...
分类:
移动开发 时间:
2015-06-08 19:27:02
阅读次数:
146
1、NSRunloopNSRunloop是一种消息循环机制,它会侦测输入源(input source)和定时源(timer source),然后做回调处理。主要作用使线程在没有任何事件处理的时候处于休眠状态,对于非主线程而言,可以防止线程在等候指令时候被杀掉(NSTimer调用)。其原理图如下:每个...
分类:
其他好文 时间:
2015-06-07 12:27:58
阅读次数:
1696