在 iOS4 中有没有办法在延迟后使用 NSThread 以外的其他东西调用方法或使用 sleep() 阻塞 UI?
最佳答案
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
});
关于iphone - 延迟后不使用 NSThread 或 sleep() 执行方法 - 还有其他选择吗?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/6665467/