在ios7中,UITableViewCell左侧会有默认15像素的空白。这时候,设置setSeparatorInset:UIEdgeInsetsZero 能将空白去掉。
但是在ios8中,设置setSeparatorInset:UIEdgeInsetsZero 已经不起作用了。下面是解决办法
1:这个我自己的方法
直接在cellForRowAtIndexPath方法中添加:
if ([cell respondsToSelector:@selector(setLayoutMargins:)]) {
[cell setLayoutMargins:UIEdgeInsetsZero];
}
if ([self.table respondsToSelector:@selector(setSeparatorInset:)]) {
[self.table setSeparatorInset:UIEdgeInsetsMake(0, 0, 0, 0)];
}
搞定
2:下面百其他iOS工程师的方法
首先在viewDidLoad方法中加上如下代码:
然后在willDisplayCell方法中加入如下代码:
这样,空白就没有了