想要cell的分割线顶满左侧, 只需要在控制器中写上如下代码:
//将要显示cell时候
- (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];
}
}
//在由frame的改变而触发输出subview之前,这个方法被调用
- (void)viewDidLayoutSubviews {
if ([self.myTabelView respondsToSelector:@selector(setSeparatorInset:)]) {
[self.myTabelView setSeparatorInset:UIEdgeInsetsZero];
}
if ([self.myTabelView respondsToSelector:@selector(setLayoutMargins:)]) {
[self.myTabelView setLayoutMargins:UIEdgeInsetsZero];
}
}