升级到iOS 11后,痛苦的事情多起来了,以前版本没有的出现问题的代码,经过Xcode 9一编译,千万草泥马奔腾而过;
今天碰到一个奇葩问题,直接进入主题:
问题描述:
-(CGFloat)tableView:(UITableView *)tableView heightForHeaderInSection:(NSInteger)section
{
return 12;
}
-(UIView *)tableView:(UITableView *)tableView viewForHeaderInSection:(NSInteger)section
{
UIView* headerSection_V = [[UIView alloc]initWithFrame:CGRectMake(ZERODIS, ZERODIS, SCREEN_WIDTH, 12)];
[headerSection_V setBackgroundColor:COLOR_3];
return headerSection_V;
}
1- headerView 会错乱移动, 且调整tableView 的style也没有效果;
2- 滑动tableView的时候, 貌似底部又多出一个图层tableView,重复了tableViewCell的内容;
3- 以下代码无效:(当然tableVIew 懒加载的时候 还有相应代码设置cell分割线的偏移)
/**
* 解决cell分割线距离两边12 居中对齐
*/
- (void)tableView:(UITableView *)tableView willDisplayCell:(UITableViewCell *)cell forRowAtIndexPath:(NSIndexPath *)indexPath
{
if ([cell respondsToSelector:@selector(setSeparatorInset:)]) {
[cell setSeparatorInset:UIEdgeInsetsMake(ZERODIS, 12, ZERODIS, 12)];
}
if ([cell respondsToSelector:@selector(setLayoutMargins:)]) {
[cell setLayoutMargins:UIEdgeInsetsMake(ZERODIS, 12, ZERODIS, 12)];
}
}
最后排查发现:
旧代码使用了xib但是又没有用xib的tableView, tableView又是自己代码生成的, 把xib删除之后,就OK了;