Terminating app due to uncaught exception 'CALayerInvalidGeometry', reason: 'CALayer position contai

来源:互联网 发布:网络征文2016 编辑:程序博客网 时间:2024/05/17 01:05
Terminating app due to uncaught exception 'CALayerInvalidGeometry', reason: 'CALayer position contains NaN: [nan 14]'
*** Call stack at first throw:
(
0 CoreFoundation 0x365fa64f __exceptionPreprocess + 114
1 libobjc.A.dylib 0x33853c5d objc_exception_throw + 24
2 CoreFoundation 0x365fa491 +[NSException raise:format:arguments:] + 68
3 CoreFoundation 0x365fa4cb +[NSException raise:format:] + 34
4 QuartzCore 0x30a2661d _ZL18CALayerSetPositionP7CALayerRKN2CA4Vec2IdEEb + 140
5 QuartzCore 0x30a2658b -[CALayer setPosition:] + 38
6 QuartzCore 0x30a264d7 -[CALayer setFrame:] + 390
7 UIKit 0x353e5455 -[UIView(Geometry) setFrame:] + 188
8 UIKit 0x353e52c3 -[UIImageView setFrame:] + 102
9 WeiBo 0x0002df2f -[CHMyListViewController customerCellWithIndex:] + 4150
10 WeiBo 0x0002f2c5 -[CHMyListViewController tableView:cellForRowAtIndexPath:] + 3228
11 UIKit 0x354419ed -[UITableView(UITableViewInternal) _createPreparedCellForGlobalRow:withIndexPath:] + 516
12 UIKit 0x3544176b -[UITableView(UITableViewInternal) _createPreparedCellForGlobalRow:] + 34
13 UIKit 0x3543a0cd -[UITableView(_UITableViewPrivate) _updateVisibleCellsNow:] + 936
14 UIKit 0x3543927d -[UITableView layoutSubviews] + 140
15 UIKit 0x353e55fb -[UIView(CALayerDelegate) layoutSublayersOfLayer:] + 26
16 CoreFoundation 0x36567f03 -[NSObject(NSObject) performSelector:withObject:] + 22
17 QuartzCore 0x30a27bb5 -[CALayer layoutSublayers] + 120
18 QuartzCore 0x30a2796d CALayerLayoutIfNeeded + 184
19 QuartzCore 0x30a2d1c5 _ZN2CA7Context18commit_transactionEPNS_11TransactionE + 212
20 QuartzCore 0x30a2cfd7 _ZN2CA11Transaction6commitEv + 190
21 QuartzCore 0x30a38dff _ZN2CA11Transaction5flushEv + 46
22 QuartzCore 0x30a38dcd +[CATransaction flush] + 28
23 UIKit 0x35424923 -[UIApplication _reportAppLaunchFinished] + 30
24 UIKit 0x3540fc23 -[UIApplication _runWithURL:payload:launchOrientation:
statusBarStyle:statusBarHidden:] + 462
25 UIKit 0x353e47d7 -[UIApplication handleEvent:withNewEvent:] + 1114
26 UIKit 0x353e4215 -[UIApplication sendEvent:] + 44
27 UIKit 0x353e3c53 _UIApplicationHandleEvent + 5090
28 GraphicsServices 0x35d1ee77 PurpleEventCallback + 666
29 CoreFoundation 0x365d1a97 __CFRUNLOOP_IS_CALLING_OUT_TO_A_SOURCE1_PERFORM_FUNCTION__ + 26
30 CoreFoundation 0x365d383f __CFRunLoopDoSource1 + 166
31 CoreFoundation 0x365d460d __CFRunLoopRun + 520
32 CoreFoundation 0x36564ec3 CFRunLoopRunSpecific + 230
33 CoreFoundation 0x36564dcb CFRunLoopRunInMode + 58
34 UIKit 0x3540ed49 -[UIApplication _run] + 372
35 UIKit 0x3540c807 UIApplicationMain + 670
36 WeiBo 0x00003aab main + 82
37 WeiBo 0x00003a54 start + 40

这种错误是在float经过函数运行出了不是数字的值,nan的意思就是not a number。
主要常见原因:
1.除以0
2.sizeWithFont的字符串为nil
3.数学函数不正确运算
解决方法除了排除根源所在之外,用函数isnan()也是不错的选择(至少在没有彻底解决以前)
如下

float _x = NAN;
if (!isnan(_x)) {
cell.imgView.frame = CGRectMake(_x, 8, 10, 12);
}
0 0