最近在使用UITableViewController的时候总遇到非iOS 11系统下运行UISectionRowData的问题,莫名的卡死。
Xcode 9.0.1报错如下:
Assertion failure in -[UISectionRowData refreshWithSection:tableView:tableViewRowData:], /BuildRoot/Library/Caches/com.apple.xbs/Sources/UIKit_Sim/UIKit-3600.6.21/UITableViewRowData.m:443
2017-10-23 09:57:00.234 PMPH_Asiainfo[45343:756580] invalid mode 'kCFRunLoopCommonModes' provided to CFRunLoopRunSpecific - break on _CFRunLoopError_RunCalledWithInvalidMode to debug. This message will only appear once per execution.
我的代码写法是重写如下这个方法,然后整个viewControler执行完成后就报错上面提到的错误
问题代码
-(instancetype)initWithStyle:(UITableViewStyle)style {
self = [super initWithStyle:UITableViewStyleGrouped];
if (self) {
self.tableView.rowHeight = UITableViewAutomaticDimension;
self.tableView.estimatedRowHeight = 80;
self.tableView.sectionFooterHeight = 10;
self.tableView.sectionHeaderHeight = 0.1;
self.tableView.estimatedSectionHeaderHeight = 0.1;
self.tableView.estimatedSectionFooterHeight = 10;
self.tableView.separatorStyle = UITableViewCellSeparatorStyleNone;
[self.tableView registerNib:[UINib nibWithNibName:@"ResultInfoOneViewCell" bundle:nil] forCellReuseIdentifier:@"ResultInfoOneViewCell"];
[self.tableView registerNib:[UINib nibWithNibName:@"ResultInfoTwoViewCell" bundle:nil] forCellReuseIdentifier:@"ResultInfoTwoViewCell"];
}
return self;
}
我的解决办法是:注释掉如下这几个设置
// self.tableView.sectionFooterHeight = 10;
// self.tableView.sectionHeaderHeight = 0.1;
// self.tableView.estimatedSectionHeaderHeight = 0.1;
// self.tableView.estimatedSectionFooterHeight = 10;
然后通过代理方法来设置值,就完全解决这个问题了。
但是还是不明白原理,为什么这样使用会报错,在iOS 11运行就没有问题,知道原因的大神,请告知一下。