gpt4 book ai didi

iphone - 延迟后不使用 NSThread 或 sleep() 执行方法 - 还有其他选择吗?

转载 作者:IT王子 更新时间:2023-10-29 08:13:47 26 4
gpt4 key购买 nike

在 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/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com