UIViewController 动画停止工作 [英] UIViewController animations stop working
问题描述
我的应用程序在 iOS6 中运行良好,但在未指定的即将推出的 iOS 版本中,由于保密协议的原因我无法命名,所有 UIViewController
过渡动画都停止工作.新视图会立即出现.我不确定这个未指明的未来版本的 iOS 是否是原因,因为我在 iOS6 中偶尔会看到这种情况.
My app runs fine in iOS6, but in an unspecified upcoming version of iOS that I cannot name for NDA reasons, all UIViewController
transition animations stop working. New views just pop into place instantly. I am not sure if this unspecified future version of iOS is the cause, as I've seen this happen occasionally in iOS6.
有时动画开始工作一段时间然后很快停止,让我认为这是某种内存警告问题,但我的应用程序在大多数情况下使用了相当合理的 ~125MB RAM.任何人都可以提供任何建议或调查事项吗?
Sometimes animations start working for a while and then stop shortly after, making me think it's some sort of memory warning issue, but my app is using a fairly reasonable ~125MB of RAM at most times. Can anyone offer any advice or things to investigate?
推荐答案
所描述的行为一直存在:如果你在后台线程上工作,然后调用 UIKit 方法,那么更新通常会以一种奇怪的方式延迟方式.
The described behavior has always existed: if you do work on background threads and then call and UIKit methods then more often than not the update will be delayed in a weird way.
因此,您应该始终dispatch_async
到主队列以更新 UI.
Because of this you should always dispatch_async
onto the main queue to update the UI.
这些错误很难被发现,因为它们并不总是在可预见的情况下发生.
Those bugs are very hard to catch since they do not always occur predictably.
为了捕捉它们,我构建了一个方法来混合一些 UIKit 方法来检查它们是否在主线程上被调用.这允许您在忘记分派回主队列时在符号断点处停止.
To catch them I built a method that swizzles some UIKit methods to check if they are called on the main thread. This allows you to stop on a symbolic breakpoint, whenever you have forgotten to dispatch back onto main queue.
https://github.com/Cocoanetics/DTFoundation/blob/develop/Core/Source/iOS/Debug/UIView%2BDTDebug.m
这篇关于UIViewController 动画停止工作的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!