(iphone)pushViewController 在后台线程中?
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 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
这里有几个策略。
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.