NStimer 倒计时显示应用程序重新打开时的旧时间 - iPhone 拍摄屏幕图像?
我的 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 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
我的理解是,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.