升级到XCode6后,iOS8里设置tableview的setSeparatorInset:UIEdgeInsetsZero不起作用的解决办法
2024-08-28 03:39:16
我们在使用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];
}
}
这样就可以正常显示了。
最新文章
- Android使用ViewPager实现左右循环滑动及轮播效果
- tp5 中 model 的更新方法
- 数据源增量处理(Delta Proess)三大属性:Recod Mode、Delta Type、Serialization
- nginx学习记录/2016.11.14
- Codeforces Round #377 (Div. 2) D. Exams(二分答案)
- 算法系列:geometry
- Drools给日志打标签
- Java学习笔记——多态性Polymorphism
- WebKit JavaScript Binding添加新DOM对象的三种方式
- 如何运行代码apk安装
- 快速构建Windows 8风格应用10-设备方向
- nodejs cluster模块初探
- 获取View组件宽度以及ViewTreeObserver
- 9.app后端选择什么服务器
- 如何理解php的依赖注入
- ASP.NET Core 统一异常处理和返回
- 第零章 HTML启蒙知识与网站开发流程
- ClientDataSet字段不能进行编辑时的解决方法
- 所以到底什么是 Growth Hacking?
- superobject