iOS 5 在填充表格之前等待委托完成?
我正在开发一个 iOS 5 应用程序。我有一个视图控制器,需要在打开后立即显示数据。所需的功能顺序是:
- 调用 Web 服务
- 等待来自 Web 服务(委托)的回复
- 填充数据数组
- 使用数组填充列表视图
- 显示列表视图
我已将所有组件就位,但在当进行 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:
- Call a web service
- Wait for the reply from the web service (a delegate)
- Fill a data array
- Use the array to populate a list view
- 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 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
如果您的意思是列表视图中的“UITableView 实例”,那么让 Web 服务完成加载,然后刷新表视图:
希望这会有所帮助。
If you mean "an UITableView instance" by list view, then let the web service finish loading, then refresh the table view:
Hope this helps.