UITableView问题汇总

1.  真机上分割线有时候显示有时候不显示的问题

     因为你在cell的layoutSubviews方法里面没有写上[super layoutSubviews];


2. uitableviewcell高度自适应 

    以前使用UITableView+FDTemplateLayoutCell在代理里面计算高度,新版的方法只需要设置uitableiview的两个属性

self.tableView.estimatedRowHeight = 100;

self.tableView.rowHeight = UITableViewAutomaticDimension;

不用在实现- (CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath的代理方法了,否则会影响高度的计算。

另外需要注意的是,用masonry配合UITableViewCell使用,会报约束冲突的问题,是因为你还是用了之前的方法,实现heightForRowAtIndexPath来计算高度,把该方法去掉就行。


3.当隐藏导航栏的时候,tableview上面和界面会出现20像素的空白

    解决方法:

if (@available(iOS 11.0, *)) {

    self.tableView.contentInsetAdjustmentBehavior = UIScrollViewContentInsetAdjustmentNever;

} else {

    self.automaticallyAdjustsScrollViewInsets = NO;

}

4.iOS 11设置了contentInsetAdjustmentBehavior 后上下滑动会抖动

if (@available(iOS 11.0, *)) {

    [UITableView appearance].estimatedRowHeight = 0;

    [UITableView appearance].estimatedSectionHeaderHeight =0;

    [UITableView appearance].estimatedSectionFooterHeight =0;

    [UITableView appearance].contentInsetAdjustmentBehavior =         UIScrollViewContentInsetAdjustmentNever;

     [UIScrollView appearance].contentInsetAdjustmentBehavior=UIScrollViewContentInsetAdjustmentNever;

}

未完待续

最后编辑于
©著作权归作者所有,转载或内容合作请联系作者
【社区内容提示】社区部分内容疑似由AI辅助生成,浏览时请结合常识与多方信息审慎甄别。
平台声明:文章内容(如有图片或视频亦包括在内)由作者上传并发布,文章内容仅代表作者本人观点,简书系信息发布平台,仅提供信息存储服务。

相关阅读更多精彩内容

友情链接更多精彩内容