第一次注意到 NaN 這個(gè)關(guān)鍵字檐蚜,雖然以前也遇到過贯城,最近出現(xiàn)了這個(gè)錯(cuò)誤之后才意識(shí)到這個(gè)意思,
2018-09-19 09:22:35.894708+0800 iCooling[48551:3911186] *** Terminating app due to uncaught exception 'CALayerInvalidGeometry',
reason: 'CALayer position contains NaN: [nan 115]'
*** First throw call stack:
(
0 CoreFoundation 0x00000001068df1e6 __exceptionPreprocess + 294
1 libobjc.A.dylib 0x0000000108967031 objc_exception_throw + 48
2 CoreFoundation 0x0000000106954975 +[NSException raise:format:] + 197
3 QuartzCore 0x00000001084fec61 _ZN2CA5Layer12set_positionERKNS_4Vec2IdEEb + 151
4 QuartzCore 0x00000001084ef362 -[CALayer setPosition:] + 43
5 QuartzCore 0x00000001084ef990 -[CALayer setFrame:] + 544
6 UIKit 0x000000010af8e7a6 __26-[_UILabelLayer setFrame:]_block_invoke + 80
7 UIKit 0x000000010af8e625 -[_UILabelLayer _setFrameOrBounds:settingAction:] + 23
8 UIKit 0x000000010af8e750 -[_UILabelLayer setFrame:] + 137
9 UIKit 0x000000010a96a4f7 -[UIView(Geometry) setFrame:] + 368
10 UIKit 0x000000010ab72605 -[UILabel setFrame:] + 141
11 UIKit 0x000000010a9576c3 UIViewCommonInitWithFrame + 1380
12 UIKit 0x000000010a957123 -[UIView initWithFrame:] + 113
13 UIKit 0x000000010ab71f59 -[UILabel initWithFrame:] + 77
14 iCooling 0x00000001055fa32c -[ZYCustomPickerView addNameLabel] + 748
15 iCooling 0x00000001055fa66a -[ZYCustomPickerView numberOfComponentsInPickerView:] + 58
看到layer認(rèn)為是界面上的賦值錯(cuò)誤鸭叙,因?yàn)槭且粋€(gè)控件觉啊,點(diǎn)的賦值不一樣,有的可以也有的不可以递雀,看堆棧上的方法調(diào)用也像在Label這一步出錯(cuò)柄延,后來一步一步打印,才知道我挖的坑(反正每天都在挖)缀程,就因?yàn)樵谟?jì)算label的frame時(shí)發(fā)現(xiàn)原來除數(shù)的時(shí)候搜吧,直接使用的變量,而這個(gè)變量為0杨凑,除數(shù)為0了滤奈,所以,就出現(xiàn)這個(gè)崩潰了撩满。在此記錄下來蜒程。