当应用程序移动到前台iOS4时,UIActivityIndi​​catorview会冻结 [英] UIActivityIndicatorview freezes when application moves to foreground iOS4

查看:106
本文介绍了当应用程序移动到前台iOS4时,UIActivityIndi​​catorview会冻结的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

当我将应用程序移动到后台然后将其恢复到前台时,我遇到活动指示器冻结的问题。当应用程序移动到后台时,应用程序可以通过网络加载一些数据。因此,我向用户显示活动指示器。我添加了代码以确保任务在后台完成。
当应用程序立即进入前台并且数据未完全加载时,微调器停留在屏幕上但停止旋转。当数据完全加载时,微调器就会消失。

I am experiencing an issue with activity indicator freezing when I move application to background and then bring it back to foreground. The application can be loading some data over the network when it is moved to background. Hence I display an activity indicator to the user. I have added the code to make sure that the task finishes in the background. When the application is brought to foreground immediately and the data is not completely loaded, the spinner stays on the screen but it stops spinning. When the data is completely loaded, the spinner disappears.

任何想法为什么活动指示器会冻结以及可能的解决方案。

Any idea why the activity indicator freezes and what could be a possible solution to it.

谢谢。

推荐答案

后台应用几乎没有理由更新其UI 。

There's almost no reason for an app in the background to be updating its UI.

对于一个人,谁来看?指示灯冻结的另一个原因是前往后台会停止UI更新和动画,不必要地耗尽设备的电量并减慢前台应用程序的速度。

For one, who is there to see it? Another reason that the indicator freezes is that going to the background stops UI updates and animations that needlessly drain the device's battery and slow down the foreground app.

来自Apple优秀的 iPhone应用程序编程指南,app委托方法 -applicationWillEnterForeground:

From Apple's excellent iPhone Application Programming Guide, the app delegate method -applicationWillEnterForeground: is called whenever the application comes into foreground.

您可以在此处覆盖此方法并添加逻辑以唤醒小部件。或者您订阅了您的课程(视图控制器等)以收听 UIApplicationWillEnterForegroundNotification 通知。如果你监听这个通知,你可以调用一个选择器来更新UI的状态,给出当时应用程序正在做什么。

You can override this method and add logic to wake up widgets here. Or you subscribe your class (view controller, etc.) to listen for the UIApplicationWillEnterForegroundNotification notification. If you listen for this notification, you could call a selector that updates the state of the UI, given whatever the application is doing at the time.

这篇关于当应用程序移动到前台iOS4时,UIActivityIndi​​catorview会冻结的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆