Ios 从复杂的滚动视图页面移动时崩溃

Ios 从复杂的滚动视图页面移动时崩溃,ios,ipad,uitableview,uiscrollview,rotation,Ios,Ipad,Uitableview,Uiscrollview,Rotation,iOS7、iPad、通用应用程序。UITabBarViewController,具有4页。一个页面(#2)非常复杂,每个页面上有一个滚动视图(足以容纳三个屏幕进行水平滚动),其中有三个表格视图 我有下面的场景来重现崩溃,但我不知道从哪里寻找修复方案: -最初,应用程序以第1页处于活动状态开始 -用户进入第2页 -旋转设备,进行一些数据刷新 -返回到第1页 我可以看到,第2页调用了viewWillDissapear,但从未调用ViewDidDesive。我在main.c中遇到一个崩溃,堆栈跟踪如下

iOS7、iPad、通用应用程序。UITabBarViewController,具有4页。一个页面(#2)非常复杂,每个页面上有一个滚动视图(足以容纳三个屏幕进行水平滚动),其中有三个表格视图

我有下面的场景来重现崩溃,但我不知道从哪里寻找修复方案: -最初,应用程序以第1页处于活动状态开始 -用户进入第2页 -旋转设备,进行一些数据刷新 -返回到第1页

我可以看到,第2页调用了viewWillDissapear,但从未调用ViewDidDesive。我在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

你知道去哪里找问题吗

TL;DR:请注意页面中某些大小(宽度/高度)为0的
UIScrollView
实例

我想我明白了

作为我复杂视图的一部分,有一个
UIScrollView
(我们称之为
SV1
),在某个时候我需要隐藏它。为了隐藏滚动视图,我将其帧设置为CGRectZero

在离开页面的过程中,该零滚动视图的superview(
V2
)被从其superview中删除,并且由于某种原因导致了崩溃(我验证了在
视图期间尝试手动删除V2将消失
,并且我能够得到完全相同的崩溃


为了修复它,我没有将CGRectZero分配给scrollview SV1,而是在当时(当我需要隐藏它时)将其从superview V2中删除。这解决了我的问题。希望它能帮助其他人。

看起来您正在使用CGRect中不是数字的值设置UIView的边界。您在这些转换期间设置了任何视图的边界吗?您说的“这些”是什么意思转换?我在旋转时做一些手动布局,但在从一个tabbar页面转到另一个tabbar页面时,我没有做任何特殊的事情→ 第2页→ 第1页。其他人也有同样的问题,但似乎没有得到解决:根据评论,你在应用比例变换吗?不。我从一页转到另一页时不会做任何自定义的事情