Sle*_*lee 17 iphone objective-c ipad ios
有没有办法在iOS4中使用除NSThread以外的其他东西延迟调用方法或使用sleep()阻止UI?
Mar*_*ves 29
double delayInSeconds = 2.0;
dispatch_time_t popTime = dispatch_time(DISPATCH_TIME_NOW, delayInSeconds * NSEC_PER_SEC);
dispatch_after(popTime, dispatch_get_main_queue(), ^(void){
// code to be executed on main thread.If you want to run in another thread, create other queue
});
Run Code Online (Sandbox Code Playgroud)
- (void)performSelector:(SEL)aSelector withObject:(id)anArgument afterDelay:(NSTimeInterval)delay
Run Code Online (Sandbox Code Playgroud)
的NSObject会为你做到这一点.
此外,您可以创建一个NSTimer并让它在给定的时间后对某个目标和选择器执行回调.
| 归档时间: |
|
| 查看次数: |
5999 次 |
| 最近记录: |