iOS 5 在填充表格之前等待委托完成?

发布于 2024-12-27 09:31:47 字数 391 浏览 1 评论 0原文

我正在开发一个 iOS 5 应用程序。我有一个视图控制器,需要在打开后立即显示数据。所需的功能顺序是:

  1. 调用 Web 服务
  2. 等待来自 Web 服务(委托)的回复
  3. 填充数据数组
  4. 使用数组填充列表视图
  5. 显示列表视图

我已将所有组件就位,但在当进行 Web 服务调用时,程序不会等待回复(异步调用),而是用空白填充列表视图,因为数据数组尚未准备好。

因此,我需要帮助(1)让程序等待委托完成填充数组,然后填充列表视图,或者(2)在委托完成后重新初始化列表视图并重新填充整个列表视图。如果我移动列表视图(如向下滚动),我会看到所需的数据,因为视图已重新初始化。所以我知道我已经准备好了所有组件,我只需要让它们按所需的顺序工作即可。

I am working on an iOS 5 app. I have a view controller that needs to display data as soon as its opened. The desired order of functionality is:

  1. Call a web service
  2. Wait for the reply from the web service (a delegate)
  3. Fill a data array
  4. Use the array to populate a list view
  5. Show the list view

I have all of the components in place but after the web service call is made, the program doesn't wait for a reply (asynchronous call) and instead fills the list view with blanks since the data array is not quite ready.

So I need help with either (1) making the program wait until the delegate finishes filling the array and then populating the list view or (2) re-initializing the listview after the delegate has completed and re-populating the whole list view. If I move the list view (like a scroll down) I see the desired data because the view is re-initialized. So I know that I have all the components in place, I just need to make them work in the desired order.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

转身以后 2025-01-03 09:31:47

如果您的意思是列表视图中的“UITableView 实例”,那么让 Web 服务完成加载,然后刷新表视图:

- (void) myWebServiceDidFinishLoadingData
{
    [self.tableView reloadData];
}

希望这会有所帮助。

If you mean "an UITableView instance" by list view, then let the web service finish loading, then refresh the table view:

- (void) myWebServiceDidFinishLoadingData
{
    [self.tableView reloadData];
}

Hope this helps.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文