(iphone)pushViewController 在后台线程中?

发布于 2024-10-28 04:38:23 字数 531 浏览 0 评论 0原文

​​iPhone SDK - 使用performSelectorInBackground泄漏内存

似乎建议您实际上可以在后台推送ViewController线。

但我收到 stackoverflow 人员的警告,说我不应该这样做。
例如。 (iphone) 从后台线程启动计时器?

PushViewController 是否被视为“UI 更新” ?
(因为我知道 UI 更新应该只在主线程中完成)

如果是这样,
当 viewController 需要一段时间才能加载,并且想要在加载时显示指示器时。
我的选择是什么?

IPhone SDK - Leaking Memory with performSelectorInBackground

seems to suggest you can actually pushViewController in background thread.

But I get a warning from stackoverflow people that I shouldn't do this.
eg. (iphone) start timer from background thread?

is pushViewController considered "UI updating"?
(because I know that UI updating should be done in main thread only)

If it is so,
when a viewController takes a while to load, and want to show an indicator while loading.
What is my option?

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

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

发布评论

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

评论(1

作死小能手 2024-11-04 04:38:23

这里有几个策略。

1) 在执行推送之前,但在您知道要执行此操作时,在当前视图上调出合适的活动视图。我在某些应用程序中执行此操作,您单击表格中的一行,但推送的视图必须执行一些需要时间的网络通信,因此我将表格单元格以蓝色突出显示,并在披露指示器的左侧添加一个白色微调器。效果很好。

2)使用延迟加载来快速地将新的视图控制器显示在屏幕上,但将繁重的代码推迟到加载之后,以便新的控制器可以照顾它自己的活动视图。通过延迟加载,我的意思是您应该在 init 方法中尽可能少地执行操作,并仔细使用 viewdidload / viewwillappear / viewdidappear 等来分散工作并尽快在屏幕上获取活动视图。

Couple of strategies here.

1) BEFORE you do the push, but at the point you know you are going to do it, bring up a suitable activity view on the current view. I do this in some apps where you click on a row in a table but the pushed view has to do some web comms that takes time, so I leave the table cell highlighted in blue and add a white spinner to the left of the disclosure indicator. Works well.

2) Use lazy loading to get the new view controller on screen quickly, but defer the heavy code until after it has loaded so that the new controller can look after it's own activity view. By lazy loading I mean you should do as little as possible in the init method and make careful use of viewdidload / viewwillappear / viewdidappear etc to spread the work out and get an activity view on screen as soon as you can.

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