iOS 5在填充表格之前等待委托完成? [英] iOS 5 Wait for delegate to finish before populating a table?

查看:60
本文介绍了iOS 5在填充表格之前等待委托完成?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

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

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. 呼叫网络服务

  2. 等待来自Web服务(代理)

  3. 填充数据数组

  4. 使用数组填充列表视图

  5. 显示列表视图

  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

我已经准备好所有组件但是在进行Web服务调用之后,程序没有等待回复(异步调用),而是用空格填充列表视图,因为数据数据还没有准备好。

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.

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

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.

推荐答案

如果你的意思是列表视图中的UITableView实例,然后让web服务完成加载,然后刷新表视图:

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];
}

希望这有帮助。

这篇关于iOS 5在填充表格之前等待委托完成?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆