iOS 定时器

2017-01-04  本文已影响0人  Justin_W

iOS中定时器的几种方法 :

1>  [self performSelector:@selector(<#selector#>) withObject:<#(nullable id)#> afterDelay:<#(NSTimeInterval)#>];

2> dispatch_after(dispatch_time(DISPATCH_TIME_NOW, (int64_t)(<#delayInSeconds#> * NSEC_PER_SEC)), dispatch_get_main_queue(), ^{

<#code to be executed after a specified delay#>

});

3>[NSTimer scheduledTimerWithTimeInterval:<#(NSTimeInterval)#> target:<#(nonnull id)#> selector:<#(nonnull SEL)#> userInfo:<#(nullable id)#> repeats:<#(BOOL)#>];

4> displayLink = [CADisplayLink displayLinkWithTarget:self selector:@selector(handleDisplayLink:)];

[displayLink addToRunLoop:[NSRunLoop currentRunLoop] forMode:NSDefaultRunLoopMode];

[displayLink invalidate];

displayLink = nil;

上一篇 下一篇

猜你喜欢

热点阅读