我们在使用tableview时会发现分割线的左边会短一些,通常可以使用 setSeparatorInset:UIEdgeInsetsZero 来解决。但是升级到XCode6之后,在iOS8里发现没有效果。下面给出解决办法:

首先在viewDidLoad方法中加上如下代码:

if ([self.tableView respondsToSelector:@selector(setSeparatorInset:)]) {

[self.tableView setSeparatorInset:UIEdgeInsetsZero];

}

if ([self.tableView respondsToSelector:@selector(setLayoutMargins:)]) {

[self.tableView setLayoutMargins:UIEdgeInsetsZero];

}

然后在willDisplayCell方法中加入如下代码:

- (void)tableView:(UITableView *)tableView willDisplayCell:(UITableViewCell *)cell forRowAtIndexPath:(NSIndexPath *)indexPath

{

if ([cell respondsToSelector:@selector(setSeparatorInset:)]) {

[cell setSeparatorInset:UIEdgeInsetsZero];

}

if ([cell respondsToSelector:@selector(setLayoutMargins:)]) {

[cell setLayoutMargins:UIEdgeInsetsZero];

}

}

这样就可以正常显示了。

最新文章

  1. Android使用ViewPager实现左右循环滑动及轮播效果
  2. tp5 中 model 的更新方法
  3. 数据源增量处理(Delta Proess)三大属性:Recod Mode、Delta Type、Serialization
  4. nginx学习记录/2016.11.14
  5. Codeforces Round #377 (Div. 2) D. Exams(二分答案)
  6. 算法系列:geometry
  7. Drools给日志打标签
  8. Java学习笔记——多态性Polymorphism
  9. WebKit JavaScript Binding添加新DOM对象的三种方式
  10. 如何运行代码apk安装
  11. 快速构建Windows 8风格应用10-设备方向
  12. nodejs cluster模块初探
  13. 获取View组件宽度以及ViewTreeObserver
  14. 9.app后端选择什么服务器
  15. 如何理解php的依赖注入
  16. ASP.NET Core 统一异常处理和返回
  17. 第零章 HTML启蒙知识与网站开发流程
  18. ClientDataSet字段不能进行编辑时的解决方法
  19. 所以到底什么是 Growth Hacking?
  20. superobject

热门文章

  1. JQGrid 导出Excel 获取筛选条件
  2. poj 2387 Til the Cows Come Home(dijkstra算法)
  3. highcharts 从后台动态改变数据
  4. Centos 7 安装jdk1.7
  5. 安装Vue.js devtools
  6. PKUWC 2019 自闭记
  7. Linux汇编教程04:寻址方式
  8. 爬虫===登陆CSDN的方法
  9. 5-3 Linux内核计时、延时函数与内核定时器【转】
  10. Linux配置Tomcat