@import url(http://i.cnblogs.com/Load.ashx?type=style&file=SyntaxHighlighter.css);@import url(/css/cuteeditor.css);
@import url(http://i.cnblogs.com/Load.ashx?type=style&file=SyntaxHighlighter.css);@import url(/css/cuteeditor.css);
@import url(http://i.cnblogs.com/Load.ashx?type=style&file=SyntaxHighlighter.css);@import url(/css/cuteeditor.css);
1. NSTimer,可以设置一段时间执行一次,不会卡住线程
//NSTimer不准确,CADisplayLink准确
self.timer = [NSTimer scheduledTimerWithTimeInterval:3.0target:self selector:@selector(roll) userInfo:nil repeats:NO];
//NSDefaultRunLoopMode 一旦有滚动事件,默认模式暂时不监听
//NSRunLoopCommonModes 滚动模式时监听
self.timer = [NSTimer timerWithTimeInterval:1.0 target:self selector:@selector(roll) userInfo:nil repeats:YES];
[[NSRunLoop currentRunLoop] addTimer:_timer forMode:NSRunLoopCommonModes];
//结束方法
[self.timer invalidate];
2.GCD的方法,可以选择在子线程远行
dispatch_after(dispatch_time(DISPATCH_TIME_NOW, (int64_t)(1.0 * NSEC_PER_SEC)), dispatch_get_main_queue(), ^{
[self roll];
});
dispatch_after(dispatch_time(DISPATCH_TIME_NOW, (int64_t)(3.0 * NSEC_PER_SEC)), dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0), ^{
[self roll];
});
3.延时执行,不会卡住线程
[self performSelector:@selector(roll) withObject:nil afterDelay:3.0];
4.会卡住线程,不推荐使用
[NSThread sleepForTimeInterval:3.0];
@import url(http://i.cnblogs.com/Load.ashx?type=style&file=SyntaxHighlighter.css);@import url(/css/cuteeditor.css);
ipa包如何打包?ios打包ipa的四种方法分享
今天带来的内容是ios打包ipa的四种方法.总结一下,目前.app包转为.ipa包的方法有以下几种,下面一起来看看吧! 1.Apple推荐的方式,即实用xcode的archive功能 Xco ...
iOS:延时执行的三种方式
延时执行的三种方式:performSelectorXXX方法.GCD中延时函数.创建定时器 第一种方式:NSObject分类当中的方法,延迟一段时间调用某一个方法 @interface NSObj ...
iOS设置圆角的四种方法
小小圆角问题,正常情况下,我们不需要过多关心,但当屏幕内比较多的时候,还是有必要了解下性能问题的 一.设置CALayer的cornerRadius 这是最常用的,也是最简单的. cornerRadiu ...
STM32延时函数的四种方法
单片机编程过程中经常用到延时函数,最常用的莫过于微秒级延时delay_us()和毫秒级delay_ms().本文基于STM32F207介绍4种不同方式实现的延时函数. 1.普通延时 这种延时方式应该是 ...
Shell脚本执行的四种方法
(1).bash(或sh) [脚本的相对路径或绝对路径] [xf@xuexi ~]$ cat a.sh #!/bin/bash echo "hello world!" [xf@xu ...
Android延时执行的几种方法
开启新线程 new Thread(new Runnable(){ public void run(){ Thread.sleep(XXXX); handler.sendMessage(); //告诉主 ...
Android 延时执行的几种方法
开启新线程 new Thread(new Runnable(){ public void run(){ Thread.sleep(XXXX); handler.sendMessage(); //告诉主 ...
iOS中延时执行的几种方式的比较和汇总
本文列举了四种延时执行某函数的方法及其一些区别.假如延时1秒时间执行下面的方法. - (void)delayMethod { NSLog(@"execute"); } 1.perf ...
IOS中延时执行的几种方式的比较
本文列举了四种延时执行某函数的方法及其一些区别.假如延时1秒时间执行下面的方法. - (void)delayMethod { NSLog(@"execute"); } 1.perf ...
随机推荐
JQuery_元素属性操作
除了对元素内容进行设置和获取,通过jQuery 也可以对元素本身的属性进行操作,包括获取属性的属性值.设置属性的属性值,并且可以删除掉属性.
c#中读取数据库bit布尔字段数据转换Int和bool时的错误
数据库里bit这个布尔类型的字段,非常实用,但是在c#里读取时,许多人喜欢犯一些错误,导致运行报错. 实际中,有效的正确读取方法只有以下两种: int xxx= Convet.ToInt16(read ...
机器学习基石:05 Training versus Testing
train:A根据给定训练集D在H中选出g,使得Ein(g)约等于0: test:g在整个输入空间X上的表现要约等于在训练集D上的表现,使得Eout(g)约等于Ein(g). 如果|H|小,更易保证t ...
Thrift关键字
在编译thrift文件的时候发现报了如下的错误 Cannot use reserved language keyword: "class" 后来查了一下,发现class是thrif ...
13. The Impact of New Technology on Business 新科技对商务的影响
13. The Impact of New Technology on Business 新科技对商务的影响 (1) New technology links the world as never b ...
DB2如何将数据库表解锁
死锁是应用程序争抢资源造成de,把相关应用程序结束掉就可以解除死锁了 先用list application for database yourdatabasename show detail 来看看应 ...