当视图控制器的内容未收费时阻止 UITabBarController

发布于 2024-12-04 13:14:52 字数 321 浏览 2 评论 0原文

我正在做一个使用 TabBarController 的应用程序,每个选项卡都使用自己的导航控制器。

该应用程序具有动态内容,我使用 viewDidDisappear viewDidAppear 方法来创建或销毁每次进入或退出 ViewController 时所需的对象。

我的问题是,当我开始快速航行时,我没有时间加载用于上传内容(例如 XML peta 应用程序)的线程或在离开 ViewController 时销毁对象。

我如何控制导航栏或 tabbarviewcontroller 的选项卡在视图控制器加载所有内容之前不响应?

如果我表达得不好请见谅。谢谢!

I'm doing an app that uses a TabBarController and each Tab uses its own navigation controller.

The app has dynamic content and I use viewDidDisappear viewDidAppear methods to create or destroy the objects that I need each time I enter or exit into the ViewController.

My problem is when I start to sail very fast and I don't give time to load the Threads that I use for uploading content such as XML peta app or destroy objects when I leave the ViewController.

How I could control the tabs of the navigationbar or tabbarviewcontroller for not respond until the viewcontroller has loaded all contents?

Excuse me if I'm not well expressed. Thanks!

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

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

发布评论

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

评论(2

余生共白头 2024-12-11 13:14:52

无论您使用同步请求还是异步请求,只需在加载数据时显示一个 UIAlertView 即可。这既会通知用户正在加载某些内容,也会阻止与屏幕上所有其他视图的交互。

No matter you use synchronous request or asynchronous request, just show an UIAlertView while loading the data. This will both serve as a notification to the user that something is being loaded, and the it will block the interactions with all the other views on the screen.

望笑 2024-12-11 13:14:52

正如其他人在评论中所建议的那样,我相信您想要做的是重新安排事件的触发顺序。也许是这样的:

  • 在 viewWillAppear: 上,清除(或禁用或适当的)不再有效的对象并开始加载新内容线程。也许显示 UIActivityIndi​​cator 或类似的。
  • 在 viewWillDisappear: 上,告诉加载新内容线程它可以停止,不再需要其结果。如果您放置了活动指示器,请将其取下。
  • 在加载新内容线程结束时,取下所有活动指示器,用新内容更新 UI 并激活。

我真的没有看到任何解决办法——如果 UI 在新内容加载之前无效,那么你必须等待它。

另一种解决方案可能是缓存上次获取的内容,并始终在 viewDidLoad 上显示这些内容。然后,在新内容线程的末尾,缓存新内容并更新 UI。

As others have suggested in comments, I believe that what you want to do is rearrange the order in which things are triggered. Perhaps something like this:

  • On viewWillAppear:, clear (or disable or whatever is appropriate) your objects that are no longer valid and begin the load-new-content thread. Perhaps display a UIActivityIndicator or similar.
  • On viewWillDisappear:, tell the load-new-content thread that it can stop, its results are no longer needed. If you put up an activity indicator, take it down.
  • At the end of the load-new-content thread, take down any activity indicator, update the UI with the new contents and activate.

I don't really see any way around this -- if the UI is not valid until the new content is loaded, then you have to wait for it.

Another solution might be to cache the contents from the previous fetch, and always display those on viewDidLoad. Then, at the end of your new-content-thread, cache the new contents, and update the UI.

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