iPhone 在等待结果时帮助使用 XMLParser 和 UI

发布于 2024-07-29 21:53:09 字数 783 浏览 1 评论 0原文

有人可以提供一些有关处理 iPhone UI 和解析 SOAP 消息时处理的最佳方法的指导吗? 上下文如下:

  • 我有一个应用程序,允许用户选择他们有兴趣查看的汽车(从汽车列表中)。
  • 当他们挑选一辆车时,我会推送一个显示汽车详细信息类别的 carDetails 视图控制器。 当我初始化 carDetails 时,我分配/执行另一个名为 getCarData 的类,该类包含从 Web 服务检索和加载所有汽车详细信息的 SOAP 和 XMLParser 方法。
  • 目前, getCarData 类在完成处理之前将控制权返回给 carDetails (我相信是由于 XMLParser 的异步性质),
  • 但在允许用户选择任何向下钻取类别信息之前,我需要加载 getCarData 中的数据在汽车详细信息(即内饰、发动机等)中,

我的问题是;

  • 处理数据加载之前的等待过程的最佳方法是什么?
  • 我见过一些关于触发单独线程的论坛问题,因此我不会占用用户界面,但我实际上确实希望用户等待(如果有必要)直到数据加载。 那么我应该创建另一个线程吗? 我是否应该简单地显示一个隐藏主窗口的进度窗口,直到加载数据?
  • 检查并查看数据是否已完成加载以及如果没有完成则显示活动/进度视图的最佳方法是什么? 换句话说,我应该在 carDetails、getCarData 还是 AppDelegate 中处理它?

对于多个问题和(可能)新手问题感到抱歉,但我似乎找不到很多可以使用的讨论或代码示例。

预先感谢 - 迈克

can someone provide a little guidance on the best way to handle iPhone UI and processing while parsing a SOAP message? Here is the context:

  • I have an app that allows a user to select a car (from a list of cars) they are interested in viewing.
  • When they pick a car, I push a carDetails viewcontroller that shows the car detail categories. When I initialize carDetails, I alloc/execute another class called getCarData that contains SOAP and XMLParser methods that retrieve and load all the car details from a web service.
  • Currently, the getCarData class returns control back to carDetails before it has completed it's processing (I believe due to the asynchronous nature of the XMLParser)
  • But I need data from getCarData to be loaded before I allow the user to select any drill-down category information in carDetails (i.e. Interior, Engine, etc.)

My questions are;

  • What is the best way to handle the wait process until the data is loaded?
  • I have seen some forum questions on firing off separate threads so I don't tie up the UI, but I actually do want the user to wait (if necessary) until the data is loaded. So should I create another thread? Should I just simply display a progress window that hides the main window until data is loaded?
  • What is the best way to check and see if the data has finished loading and if not, display the activity/progress view? In other words, should I handle it in the carDetails, getCarData, or maybe the AppDelegate?

Sorry for the multiple questions and (probably) noob problems, but I can't seem to find many discussions or code examples that I can use.

Thanks in advance - Mike

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

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

发布评论

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

评论(1

心安伴我暖 2024-08-05 21:53:10

Apple 在这种情况下使用的典型协议是定义一个在处理/加载完成时调用的方法。 该方法可以这样调用:

-(void)carDetailsDidFinishLoading

您可以等待该方法被调用,然后才允许用户在界面中选择内容。 保持一切禁用状态,直到触发为止。

由于您实际上是冻结了界面,因此您可能需要显示一个加载符号 UIActivityIndi​​cator,以让用户知道您的应用程序并没有冻结。

The typical protocol used by Apple in this situation is to define a method to be called when the processing/loading is done. The method could be called something like this:

-(void)carDetailsDidFinishLoading

You can wait for this method to be called before allowing the user to select things in your interface. Keep everything disabled until this fires.

Since you're essentially freezing your interface, you will probably want to display a loading symbol, UIActivityIndicator, to let the user know your app hasn't just frozen.

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