当应用程序移动到前台 iOS4 时 UIActivityIndi​​catorview 冻结

发布于 2024-09-10 06:01:32 字数 207 浏览 5 评论 0原文

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

知道为什么活动指示器冻结以及可能的解决方案是什么。

谢谢。

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.

Thanks.

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

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

发布评论

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

评论(1

套路撩心 2024-09-17 06:01:32

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

其一,谁能看到它?指示器冻结的另一个原因是,进入后台会停止 UI 更新和动画,从而不必要地耗尽设备电池并减慢前台应用程序的速度。

来自 Apple 优秀的 iPhone 应用程序编程指南 ,应用程序委托方法-applicationWillEnterForeground: 每当应用程序进入前台时都会被调用。

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

There's almost no reason for an app in the background to be updating its 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.

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

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.

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