gpt4 book ai didi

ios - 对方法进行排队,以便在 iOS 应用程序中更快地加载 View

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

我正在使用以下代码向服务器请求填充 TableView :

当前的问题是,发出此请求的 View 在被用户调用时需要很长时间才能从上一个 View 加载。我怎样才能对它进行排队,以便先加载 View ,然后再加载表的数据?我试过移动 [self citySearchArrayMethod]; 但随后 View 加载速度很快,但表格是空的。

dispatch_queue_t jsonParsingQueue = dispatch_queue_create("jsonParsingQueue", NULL);

// execute a task on that queue asynchronously
dispatch_async(jsonParsingQueue, ^{


// some code on a main thread (delegates, notifications, UI updates...)
dispatch_async(dispatch_get_main_queue(), ^{

[self citySearchArrayMethod]; // populates the city table with city list

});
});

最佳答案

dispatch_queue_t jsonParsingQueue = dispatch_queue_create("jsonParsingQueue", NULL);


// execute a task on that queue asynchronously
dispatch_async(jsonParsingQueue, ^{

[self citySearchArrayMethod]; // populates the city table with city list

// some code on a main thread (delegates, notifications, UI updates...)
dispatch_async(dispatch_get_main_queue(), ^{

[self.tableView reloadData]; // load the table with data

});
});

关于ios - 对方法进行排队,以便在 iOS 应用程序中更快地加载 View ,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/19953319/

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