D25*_*D25 12 iphone cocoa-touch core-animation ios
我陷入了一个非常奇怪的问题.我希望你们中的许多人能够为我提供解决方案.我的应用程序经常中断,但我无法得到确切的情况.
在Log中我得到了以下内容
2011-02-10 16:22:12.914 RCA-iOS[4132:8327] modifying layer that is being finalized - 0xe43c520
2011-02-10 16:22:13.253 RCA-iOS[4132:207] modifying layer that is being finalized - 0xe43c520
2011-02-10 16:22:13.270 RCA-iOS[4132:207] modifying layer that is being finalized - 0xe43c520
2011-02-10 16:22:13.270 RCA-iOS[4132:207] modifying layer that is being finalized - 0xe43c520
2011-02-10 16:22:13.272 RCA-iOS[4132:207] *** -[CALayer frame]: message sent to deallocated instance 0xe43c520
Run Code Online (Sandbox Code Playgroud)
以下是我的Stack Trace.它打破主线程
#0 0x01978057 in ___forwarding___
#1 0x01a07b42 in __forwarding_prep_1___
#2 0x003c196a in -[UIView(Geometry) frame]
#3 0x003f5ff4 in -[UINavigationBar _getTitleViewFrame:leftViewFrame:rightViewFrame:forViews:forItemAtIndex:]
#4 0x003e5cab in -[UINavigationBar _getTitleViewFrame:leftViewFrame:rightViewFrame:forViews:]
#5 0x003f0c06 in __-[UINavigationBar layoutSubviews]_block_invoke_1
#6 0x003bdb5c in +[UIView(Animation) _performWithoutAnimation:]
#7 0x003f76bb in -[UINavigationBar layoutSubviews]
#8 0x00f59451 in -[CALayer layoutSublayers]
#9 0x00f5917c in CALayerLayoutIfNeeded
#10 0x00f5237c in CA::Context::commit_transaction
#11 0x00f520d0 in CA::Transaction::commit
#12 0x00f827d5 in CA::Transaction::observer_callback
#13 0x019e7fbb in __CFRUNLOOP_IS_CALLING_OUT_TO_AN_OBSERVER_CALLBACK_FUNCTION__
#14 0x0197d0e7 in __CFRunLoopDoObservers
#15 0x01945bd7 in __CFRunLoopRun
#16 0x01945240 in CFRunLoopRunSpecific
#17 0x01945161 in CFRunLoopRunInMode
#18 0x02129268 in GSEventRunModal
#19 0x0212932d in GSEventRun
#20 0x0039e42e in UIApplicationMain
#21 0x00001fd0 in main at main.m:14
Run Code Online (Sandbox Code Playgroud)
以下是NSZombie对象的Instrument`s输出.这指向UIKit
# Category Event Type RefCt Timestamp Address Size Responsible Library Responsible Caller
0 CALayer Malloc 1 25304068864 0x10837840 48 UIKit -[UIView _createLayerWithFrame:]
1 CALayer Zombie -1 99780847872 0x10837840 0 UIKit -[UIView(Geometry) frame]
Run Code Online (Sandbox Code Playgroud)
没有什么指向代码.有谁遇到过这种问题?如果是,请让我知道以下
1)当我们得到"修改正在最终确定的层"破坏问题?
2)是由于UIView层?例如(view.layer.cornerRadius)?
3)Stack Trace指向UINAvigationBar,有没有办法覆盖方法并试用一些东西?
任何帮助表示赞赏.谢谢
Bra*_*son 40
"modifying layer that is being finalized"当您尝试在解除分配过程中修改CALayer的属性时,会发生此错误.我已经看到这种情况发生在我不小心使用访问器清除CALayer上的属性时,在该层的-dealloc方法中.
-dealloc如果更新任何与显示相关的内容(从而触及底层CALayer),这也可能在UIView的方法中发生.
在你的情况下,由于僵尸消息,看起来你在某处过度释放UIView.这"modifying layer that is being finalized"只是一个副作用,因为在某些时候你会在它应该被解除分配之前更新UIView.
打开断点,确保在抛出异常时设置断点,并在调试器中运行应用程序.它应该停止在消息被发送到过度发布的UIView的行上,该UIView应该告诉你哪个视图位于其中心.然后,您可以回溯以查找您发送过多释放消息的时间点(或者如果您需要超出当前范围,则自动释放而不保留).
因为您已经有指向UINavigationBar的证据,请检查它及其相关视图以确保您正确保留它.