gpt4 book ai didi

iphone - 需要时间从后台恢复应用程序,显示启动画面

转载 作者:行者123 更新时间:2023-11-29 13:19:02 26 4
gpt4 key购买 nike

我们的应用程序需要时间从 iPod 的后台恢复,因此它每次都会显示启动画面。当应用程序进入前台时,它会从缓存中加载一些数据,如果数据量很大,则需要一些时间。我该如何处理这种情况?我只是把那些方法放到dispatch queue中,但是没有什么特别的效果。

最佳答案

使用调度队列,将那些耗时的方法(从缓存中加载数据的方法)发送到后台。当它完成时,说你现在需要做一些 UI 更新,获取主队列并在那里更新 UI

dispatch_queue_t queue = dispatch_queue_create("name for the queue", NULL);
dispatch_async(queue, ^{
//your extensive code goes here, should not involve any UI updates
//If there are any UI updates involved, uncomment the following code:
/*dispatch_async(dispatch_get_main_queue(), ^{
//UI update here, as it should always be done on main thread
});*/
});

由于您在启动期间在主线程上执行繁重的计算,因此您会看到启动画面。你应该照顾它并将它移到后台,因为将来,如果从缓存加载需要很长时间,超过 10 秒,你的应用程序将被看门狗杀死。

干杯,玩得开心

关于iphone - 需要时间从后台恢复应用程序,显示启动画面,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/14846648/

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