一、如果是通过storyboard创建的静态cell,显示完整cellf分割线的方法如下:
首先选中cell,Focus Style选择Custom,下面Indentation的值设置为0,还需要设置另外一个地方为Layout Margins 选择Explicit,并将下面的值设置为0,才可以成功的解决问题。图如下所示:


二、代码创建的cell,显示完整的分割线如下的代码:
-(void)viewDidLayoutSubviews {
if ([self.tableView respondsToSelector:@selector(setSeparatorInset:)]) {
[self.tableView setSeparatorInset:UIEdgeInsetsZero];
}
if ([self.tableView respondsToSelector:@selector(setLayoutMargins:)]) {
[self.tableView setLayoutMargins:UIEdgeInsetsZero];
}
}
-(void)tableView:(UITableView *)tableView
willDisplayCell:(UITableViewCell *)cell
forRowAtIndexPath:(NSIndexPath *)indexPat{
if ([cell respondsToSelector:@selector(setLayoutMargins:)]) {
[cell setLayoutMargins:UIEdgeInsetsZero];
}
if ([cell respondsToSelector:@selector(setSeparatorInset:)]){
[cell setSeparatorInset:UIEdgeInsetsZero];
}
}
网友评论