iOS7,iPad,通用应用。 UITabBarViewController有4页。一页(#2)非常复杂,有一个滚动视图(足以容纳三个水平滚动屏幕),每页上有三个表视图。
我有以下方案重现崩溃,但我不知道在哪里挖掘修复: - 最初的应用程序从第1页激活开始 - 用户转到第2页 - 旋转设备,刷新一些数据 - 回到第1页
我可以看到viewWillDissapear是为第2页调用的,但是从不调用viewDidDisappear。我正在使用以下堆栈跟踪在main.c中崩溃:
2014-08-07 16:07:40.379 Time[10691:60b] *** Terminating app due to uncaught exception 'CALayerInvalidGeometry', reason: 'CALayer bounds contains NaN: [768 nan; 768 0]'
*** First throw call stack:
(
0 CoreFoundation 0x0258f1e4 __exceptionPreprocess + 180
1 libobjc.A.dylib 0x022328e5 objc_exception_throw + 44
2 CoreFoundation 0x0258efbb +[NSException raise:format:] + 139
3 QuartzCore 0x028f5a3b _ZN2CA5Layer10set_boundsERKNS_4RectEb + 267
4 QuartzCore 0x028f5d06 -[CALayer setBounds:] + 135
5 UIKit 0x00f50781 -[UIView(Geometry) setBounds:] + 358
6 UIKit 0x00f6d627 -[UIScrollView setBounds:] + 1036
7 UIKit 0x00f6db9b -[UIScrollView setContentOffset:] + 690
8 UIKit 0x00f86ad8 -[UIScrollView(UIScrollViewInternal) _stopScrollingNotify:pin:tramplingDragFlags:] + 423
9 UIKit 0x00f86b7e -[UIScrollView(UIScrollViewInternal) _stopScrollingNotify:pin:] + 57
10 UIKit 0x00f6e6b4 -[UIScrollView _didMoveFromWindow:toWindow:] + 106
11 UIKit 0x00f5c109 -[UIView(Internal) _didMoveFromWindow:toWindow:] + 763
12 UIKit 0x00f5c109 -[UIView(Internal) _didMoveFromWindow:toWindow:] + 763
13 UIKit 0x00f5c109 -[UIView(Internal) _didMoveFromWindow:toWindow:] + 763
14 UIKit 0x00f5c109 -[UIView(Internal) _didMoveFromWindow:toWindow:] + 763
15 UIKit 0x00f5c109 -[UIView(Internal) _didMoveFromWindow:toWindow:] + 763
16 UIKit 0x00f5c109 -[UIView(Internal) _didMoveFromWindow:toWindow:] + 763
17 UIKit 0x00f5396f __45-[UIView(Hierarchy) _postMovedFromSuperview:]_block_invoke + 158
18 Foundation 0x01fe568c -[NSISEngine withBehaviors:performModifications:] + 107
19 Foundation 0x01e753c5 -[NSISEngine withAutomaticOptimizationDisabled:] + 48
20 UIKit 0x00f53830 -[UIView(Hierarchy) _postMovedFromSuperview:] + 313
21 UIKit 0x00f51b0a __UIViewWasRemovedFromSuperview + 226
22 UIKit 0x00f5170a -[UIView(Hierarchy) removeFromSuperview] + 264
23 UIKit 0x00ff1ba6 -[UITransitionView _didCompleteTransition:] + 634
24 UIKit 0x00ff2df9 -[UITransitionView transition:fromView:toView:removeFromView:] + 3006
25 UIKit 0x00ff2233 -[UITransitionView transition:fromView:toView:] + 62
26 UIKit 0x00ff1fd3 -[UITransitionView transition:toView:] + 123
27 UIKit 0x01049526 -[UITabBarController transitionFromViewController:toViewController:transition:shouldSetSelected:] + 1438
28 UIKit 0x01048943 -[UITabBarController transitionFromViewController:toViewController:] + 63
29 UIKit 0x01044bed -[UITabBarController _setSelectedViewController:] + 281
30 UIKit 0x01044acc -[UITabBarController setSelectedViewController:] + 180
31 UIKit 0x0104883f -[UITabBarController _tabBarItemClicked:] + 312
32 libobjc.A.dylib 0x02244880 -[NSObject performSelector:withObject:withObject:] + 77
33 UIKit 0x00ef43b9 -[UIApplication sendAction:to:from:forEvent:] + 108
34 UIKit 0x00ef4345 -[UIApplication sendAction:toTarget:fromSender:forEvent:] + 61
35 UIKit 0x011b8629 -[UITabBar _sendAction:withEvent:] + 479
36 libobjc.A.dylib 0x0224482b -[NSObject performSelector:withObject:] + 70
37 UIKit 0x00ef43b9 -[UIApplication sendAction:to:from:forEvent:] + 108
38 UIKit 0x00ef4345 -[UIApplication sendAction:toTarget:fromSender:forEvent:] + 61
39 UIKit 0x00ff5bd1 -[UIControl sendAction:to:forEvent:] + 66
40 UIKit 0x00ff5fc6 -[UIControl _sendActionsForEvents:withEvent:] + 577
41 UIKit 0x00ff5c06 -[UIControl sendActionsForControlEvents:] + 48
42 UIKit 0x011bd23d -[UITabBar(Static) _buttonUp:] + 123
43 libobjc.A.dylib 0x02244880 -[NSObject performSelector:withObject:withObject:] + 77
44 UIKit 0x00ef43b9 -[UIApplication sendAction:to:from:forEvent:] + 108
45 UIKit 0x00ef4345 -[UIApplication sendAction:toTarget:fromSender:forEvent:] + 61
46 UIKit 0x00ff5bd1 -[UIControl sendAction:to:forEvent:] + 66
47 UIKit 0x00ff5fc6 -[UIControl _sendActionsForEvents:withEvent:] + 577
48 UIKit 0x00ff5243 -[UIControl touchesEnded:withEvent:] + 641
49 UIKit 0x00f33ddd -[UIWindow _sendTouchesForEvent:] + 852
50 UIKit 0x00f349d1 -[UIWindow sendEvent:] + 1117
51 UIKit 0x00f065f2 -[UIApplication sendEvent:] + 242
52 UIKit 0x00ef0353 _UIApplicationHandleEventQueue + 11455
53 CoreFoundation 0x0251877f __CFRUNLOOP_IS_CALLING_OUT_TO_A_SOURCE0_PERFORM_FUNCTION__ + 15
54 CoreFoundation 0x0251810b __CFRunLoopDoSources0 + 235
55 CoreFoundation 0x025351ae __CFRunLoopRun + 910
56 CoreFoundation 0x025349d3 CFRunLoopRunSpecific + 467
57 CoreFoundation 0x025347eb CFRunLoopRunInMode + 123
58 GraphicsServices 0x048235ee GSEventRunModal + 192
59 GraphicsServices 0x0482342b GSEventRun + 104
60 UIKit 0x00ef2f9b UIApplicationMain + 1225
61 Time 0x001d3832 main + 130
62 libdyld.dylib 0x02e26701 start + 1
)
libc++abi.dylib: terminating with uncaught exception of type NSException
知道在哪里寻找问题?
答案 0 :(得分:1)
TL; DR:请注意页面中UIScrollView
的一些实例,其中包含0个大小(宽度/高度)。
我想我想出来了。
作为我的复杂视图的一部分,有一个UIScrollView
(我们称之为SV1
),在某些时候我需要隐藏它。要隐藏该滚动视图,我将其框架设置为CGRectZero。
在离开页面期间,该超级视图的超级视图(V2
)正在从其超级视图中删除,并且由于某种原因导致崩溃(我通过尝试在{{{}期间手动删除V2来验证1}}我能够完全相同的崩溃。
要修复它 - 而不是将CGRectZero分配给滚动视图SV1,我当时只是从superview V2中删除它(当我需要隐藏它时)。这解决了我的问题。希望它能帮助别人。