在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方法中加入如下代碼:
這樣,空白就沒有了