UITableViewCell的分割线不满屏的解决办法

来源:互联网 发布:excel数据四舍五入取整 编辑:程序博客网 时间:2024/05/18 02:39

只需两步

1. - (void)viewDidLayoutSubviews {

    
    if ([self.myTableView respondsToSelector:@selector(setSeparatorInset:)]) {
        [self.myTableView setSeparatorInset:UIEdgeInsetsZero];      
    }
    if ([self.myTableView respondsToSelector:@selector(setLayoutMargins:)])  {
        [self.myTableView setLayoutMargins:UIEdgeInsetsZero];
    }

}


2. - (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 0
原创粉丝点击