NStimer 倒计时显示应用程序重新打开时的旧时间 - iPhone 拍摄屏幕图像?

发布于 2024-10-04 10:07:34 字数 379 浏览 0 评论 0原文

我的 iPhone 应用程序有一些奇怪的行为。我有一个倒计时的 NSTimer。当应用程序关闭时,我会保存时间并在应用程序重新打开时从当前倒计时器中减去该时间。

假设我在 03:12(3 分 12 秒)关闭应用程序。我重新打开应用程序,我的代码(在应用程序委托中)减去关闭时间(例如 5 秒),然后再次设置倒计时标签。它将时间设置为 03:07。

然而,奇怪的行为是,当我重新打开应用程序时,它会在更新为 03:07 之前显示一秒钟 03:12。然而,我找不到任何地方可以设定旧时光。

所以,我的问题是,视图是否会保留标签值直到下次加载,或者(正如我听说的)iPhone 会拍摄屏幕图像,以便下次加载应用程序时看起来加载速度更快。如果这是正确的,有办法阻止吗?

我被这个困住了!!

I have some strange behavior in my iphone app. I have an NSTimer which counts down. When the app closes, I save the time and subtract that from the current countdown timer when the app reopens.

Say I close the app at 03:12 (3 mins 12 seconds). I reopen the app and my code (in app delegate) subtracts the closed time (say 5 seconds) and will then set the countdown label again. It sets it to 03:07.

However, the strange behavior is that when I reopen the app is says 03:12 for a SPLIT second before it updates to 03:07. Yet, I cannot find ANYWHERE where it would be setting an old time.

So, my question is that does the view retain the label value until next time it loads, or is it (as I heard) that the iphone takes an image of the screen so when the app loads next time it looks like it's loading quicker. If this is right, is there a way to stop that??

I'm stuck with this one!!

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

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

发布评论

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

评论(1

倾城泪 2024-10-11 10:07:34

我的理解是,iOS 在将应用程序置于后台之前会生成关键窗口的快照,然后使用它来显示前景动画。我相信这样做是出于性能原因。

一个简单的方法是简单地将标签隐藏在应用程序委托的 applicationWillResignActive: 方法中,然后在 applicationWillEnterForeground: 方法中更新并再次显示它。

My understanding is that iOS generates a snapshot of your key window before backgrounding your app, then uses that to display the foregrounding animation. I believe this is done for performance reasons.

An easy way out would be to simply hide your label in the applicationWillResignActive: method of your app delegate and then update and show it again in your applicationWillEnterForeground: method.

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