- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
我使用以下代码无限期地对 UIView 进行动画处理:
#define DEFAULT_ANIM_SPPED 0.6
#define INFINATE_VALUE 1e100f
[UIView beginAnimations:nil context:nil];
[UIView setAnimationRepeatAutoreverses:YES];
[UIView setAnimationRepeatCount:INFINATE_VALUE];
[UIView setAnimationDuration:DEFAULT_ANIM_SPPED];
CGRect tempFrame=myView.frame;
tempFrame.origin.y -= 30;
myView.frame=tempFrame;
[UIView commitAnimations];
如果我的应用程序转到后台,然后我返回到它,所有像这样的动画现在都会停止。为什么会发生这种情况?
最佳答案
通常,当您的应用程序进入后台时,其执行会完全暂停。即使您的应用程序保持事件状态(出于位置跟踪、VoIP 或其他原因),任何绘制到屏幕上的内容 will be halted当您的应用程序进入后台状态时:
Avoid updating your windows and views. While in the background, your application’s windows and views are not visible, so you should not try to update them. Although creating and manipulating window and view objects in the background does not cause your application to be terminated, this work should be postponed until your application moves to the foreground.
事实上,如果您尝试在后台绘制 OpenGL ES 上下文,您的应用程序will immediately crash :
Do not make any OpenGL ES calls from your code. You must not create an EAGLContext object or issue any OpenGL ES drawing commands of any kind while running in the background. Using these calls causes your application to be terminated immediately.
通常,建议暂停应用程序移动到后台时的所有动画,然后在应用程序位于前台时恢复这些动画。这可以在 -applicationDidEnterBackground:
中处理和-applicationWillEnterForeground:
委托(delegate)方法,或者通过监听UIApplicationDidEnterBackgroundNotification
和UIApplicationWillEnterForegroundNotification
通知。
关于iphone - 为什么当我的应用程序转到后台时,我的无限期 UIView 动画会停止?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/4668714/
我正在对用 Java 语言编写的程序进行逆向工程。到目前为止,一切都很有意义,除了一段我根本无法理解的代码。该程序本身是流行游戏Minecraft的服务器,尽管我强烈认为这个问题与其本身无关。让我向您
在 Python 的时间模块中,有一个 sleep() 函数,可以让 Python 等待 x 秒后再继续执行程序。有没有办法无限期地执行此操作直到满足条件?例如: while True: ti
我有一个 php 脚本,它可能需要 2 到 10 分钟才能执行。它从网络上获取信息,因此它的时间取决于许多其他事物的通话速度。 我曾经每 15 分钟在 cron 上运行一次脚本,但有时只需要 2 分钟
我运行 Mac OSX 10.7 和 Xcode 4.2.1,一切都很好,直到几个小时前,当我尝试运行模拟器时,我的 xcode 突然挂起!这是发生了什么 代码构建成功,但它无限期地显示“Attach
我目前正在阅读 Ivor Horton 的 Beginning C。无论如何,我不确定的 for 在继续之前打印了我的 printf 语句两次。我确定我做错了什么,但我直接从书中复制了代码。如果重要的
我正在使用一个在下面设置 session 变量/cookie 的登录系统。 Chrome,它可以让你轻松地查看你的 cookie,显然将其标记为“当我关闭浏览器时”过期的 PHPSESSID。果然,当
任务是:尝试使用最基本的形式(如“ping 8.8.8.8”)在 python 中发送 ping。一段时间后终止 ping 命令(在终端中,将执行 Ctrl+C)并获得其输出。显示 ping 统计信息
我是一名优秀的程序员,十分优秀!