Tar*_*ang 20 iphone uitableview
我的应用程序中有自定义表格视图.我已经在表中实现了"加载更多"功能,一次加载25行.问题是在加载2次app崩溃后给出'CALayerInvalidGeometry',原因是:'CALayer position包含NaN:[160 nan]'作为OS 4.2及以上版本的错误.
在低于4.2的操作系统上,其中一个单元格丢失,表格中间有空格.它不会造成任何崩溃.但它仍然给出了上面提到的错误.
我检查看看在我的代码中可以出现0除法但我找不到任何东西.跟随堆栈跟踪我喜欢.所以我甚至无法检查这种异常发生的位置.
有人有什么想法?
0 CoreFoundation 0x020ccbe9 __exceptionPreprocess + 185
1 libobjc.A.dylib 0x022215c2 objc_exception_throw + 47
2 CoreFoundation 0x02085628 +[NSException raise:format:arguments:] + 136
3 CoreFoundation 0x0208559a +[NSException raise:format:] + 58
4 QuartzCore 0x0182396a _ZL18CALayerSetPositionP7CALayerRKN2CA4Vec2IdEEb + 177
5 QuartzCore 0x018238b5 -[CALayer setPosition:] + 42
6 QuartzCore 0x018237cc -[CALayer setFrame:] + 763
7 UIKit 0x0073c307 -[UIView(Geometry) setFrame:] + 255
8 UIKit 0x008c718a -[UITableViewCell setFrame:] + 166
9 UIKit 0x0077aa08 -[UITableView(UITableViewInternal) _createPreparedCellForGlobalRow:withIndexPath:] + 1160
10 UIKit 0x0077077f -[UITableView(UITableViewInternal) _createPreparedCellForGlobalRow:] + 75
11 UIKit 0x00785450 -[UITableView(_UITableViewPrivate) _updateVisibleCellsNow:] + 1561
12 UIKit 0x0077d538 -[UITableView layoutSubviews] + 242
13 QuartzCore 0x01828451 -[CALayer layoutSublayers] + 181
14 QuartzCore 0x0182817c CALayerLayoutIfNeeded + 220
15 QuartzCore 0x0182137c _ZN2CA7Context18commit_transactionEPNS_11TransactionE + 310
16 QuartzCore 0x018210d0 _ZN2CA11Transaction6commitEv + 292
17 QuartzCore 0x018517d5 _ZN2CA11Transaction17observer_callbackEP19__CFRunLoopObservermPv + 99
18 CoreFoundation 0x020adfbb __CFRUNLOOP_IS_CALLING_OUT_TO_AN_OBSERVER_CALLBACK_FUNCTION__ + 27
19 CoreFoundation 0x020430e7 __CFRunLoopDoObservers + 295
20 CoreFoundation 0x0200bbd7 __CFRunLoopRun + 1575
21 CoreFoundation 0x0200b240 CFRunLoopRunSpecific + 208
22 CoreFoundation 0x0200b161 CFRunLoopRunInMode + 97
23 GraphicsServices 0x02611268 GSEventRunModal + 217
24 GraphicsServices 0x0261132d GSEventRun + 115
25 UIKit 0x0071542e UIApplicationMain + 1160
Run Code Online (Sandbox Code Playgroud)
Mos*_*szi 28
我有同样的错误,因为而不是写作
- (CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath { ... }
Run Code Online (Sandbox Code Playgroud)
我写:
- (NSInteger)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath { ... }
Run Code Online (Sandbox Code Playgroud)
(注意返回值).希望这有助于某人.
Nik*_*uhe 21
堆栈跟踪看起来像UITableView忙于在发生异常时布局可见单元格.由于单元格的位置似乎设置为NaN值,因此必须询问如何发生这种情况.
假设UITableView布局代码中没有错误,唯一的方法就是tableView:heightForRowAtIndexPath:在表视图中实现委托并返回错误的高度(或者一个相应的页眉或页脚方法).
编辑以查明异常的确切原因:
我假设您从字符串的几何尺寸计算单元格的高度(使用UIStringDrawing's -[NSString sizeWithFont:]).当您将消息发送到nil值时,返回值通常为nil,0,NO,或者由all-bits-zero字表示的任何值.
对于返回结构(as sizeWithFont:)的方法,这不是真的.返回的结构体根本没有初始化,包含其元素的随机值.
在您的情况下,您可能使用了CGSize结构中未初始化的元素之一,后来证明它不是有效的IEEE 754浮点值.
附录:从clang 3.0开始,消息返回的结构被初始化为{0}(所有位为零).所以上述问题不应该再发生了.
实际上,这意味着frame从a 中获取nil UIView可以在size字段中返回未定义的值frame.这个错误让我感到困惑,我很惊讶.
| 归档时间: |
|
| 查看次数: |
18940 次 |
| 最近记录: |