iOS CALayerInvalidGeometry

iOS CALayerInvalidGeometry,ios,exception-handling,Ios,Exception Handling,我有一个应用程序正在崩溃,并显示以下消息: 由于未捕获异常“CALayerInvalidGeometry”而终止应用程序, 原因:“CALayer位置包含NaN:[2.74665e-34 NaN]” 以下是更详细的异常消息: CALayer position contains NaN: [2.74665e-34 nan] 2012-04-05 15:48:00.185 Infectious[28198:fb03] ( 0 CoreFoundation

我有一个应用程序正在崩溃,并显示以下消息:

由于未捕获异常“CALayerInvalidGeometry”而终止应用程序, 原因:“CALayer位置包含NaN:[2.74665e-34 NaN]”

以下是更详细的异常消息:

CALayer position contains NaN: [2.74665e-34 nan]
2012-04-05 15:48:00.185 Infectious[28198:fb03] (
    0   CoreFoundation                      0x0226803e __exceptionPreprocess + 206
    1   libobjc.A.dylib                     0x02820cd6 objc_exception_throw + 44
    2   CoreFoundation                      0x02210a48 +[NSException raise:format:arguments:] + 136
    3   CoreFoundation                      0x022109b9 +[NSException raise:format:] + 57
    4   QuartzCore                          0x00df3c0d _ZN2CA5Layer12set_positionERKNS_4Vec2IdEEb + 155
    5   QuartzCore                          0x00de9f55 -[CALayer setPosition:] + 68
    6   QuartzCore                          0x00de9a0a -[CALayer setFrame:] + 675
    7   UIKit                               0x00efbfb8 -[UIView(Geometry) setFrame:] + 198
    8   UIKit                               0x010071a1 -[UILabel setFrame:] + 233
    9   Infectious                          0x00010e10 -[SusceptibilityHistoryController buildHistogram:] + 9648
    10  Infectious                          0x0000db7e -[SusceptibilityHistoryController viewDidLoad] + 1742
    11  UIKit                               0x00f8fa1e -[UIViewController view] + 184
    12  UIKit                               0x00f8fd11 -[UIViewController contentScrollView] + 36
    13  UIKit                               0x00fa18fd -[UINavigationController _computeAndApplyScrollContentInsetDeltaForViewController:] + 36
    14  UIKit                               0x00fa1aef -[UINavigationController _layoutViewController:] + 43
    15  UIKit                               0x00fa1dbb -[UINavigationController _startTransition:fromViewController:toViewController:] + 303
    16  UIKit                               0x00fa285f -[UINavigationController _startDeferredTransitionIfNeeded] + 288
    17  UIKit                               0x00fa2e06 -[UINavigationController pushViewController:transition:forceImmediate:] + 989
    18  UIKit                               0x00fa2a24 -[UINavigationController pushViewController:animated:] + 62
    19  Infectious                          0x0000851d -[RecentSusceptibilityController tableView:didSelectRowAtIndexPath:] + 269
    20  UIKit                               0x00f595c5 -[UITableView _selectRowAtIndexPath:animated:scrollPosition:notifyDelegate:] + 1164
    21  UIKit                               0x00f597fa -[UITableView _userSelectRowAtPendingSelectionIndexPath:] + 201
    22  Foundation                          0x017ee85d __NSFireDelayedPerform + 389
    23  CoreFoundation                      0x0223c936 __CFRUNLOOP_IS_CALLING_OUT_TO_A_TIMER_CALLBACK_FUNCTION__ + 22
    24  CoreFoundation                      0x0223c3d7 __CFRunLoopDoTimer + 551
    25  CoreFoundation                      0x0219f790 __CFRunLoopRun + 1888
    26  CoreFoundation                      0x0219ed84 CFRunLoopRunSpecific + 212
    27  CoreFoundation                      0x0219ec9b CFRunLoopRunInMode + 123
    28  GraphicsServices                    0x0315a7d8 GSEventRunModal + 190
    29  GraphicsServices                    0x0315a88a GSEventRun + 103
    30  UIKit                               0x00ec8626 UIApplicationMain + 1163
    31  Infectious                          0x0001131b main + 187
    32  Infectious                          0x00002365 start + 53
我应该找什么

我读过,可能是零除

还有什么可能是这次坠机的嫌疑犯


谢谢

问题在于这些功能之间:

8   UIKit        -[UILabel setFrame:] + 233
9   Infectious   -[SusceptibilityHistoryController buildHistogram:] + 9648
您正在调用
label.frame=…
,并且可能以某种方式计算该值,结果是一个NaN,这意味着“不是一个数字”,并且正如您正确建议的那样,它可能是o除以零运算的结果。但它的出现还有很多其他原因:


通过名为“buildHistogram:”的函数,找到对“setFrame”或“.frame=”的调用,并找到计算位置如何变为NaN。如果涉及到除法,则可能是零除法。

我正在将标签的宽度设置为0。它可能会引起问题吗?我的代码类似于CGRect r=self.lblProgress.frame;r、 size.width=0;self.lblProgress.frame=r;