IOS8 设置TableView Separatorinset 分割线从边框顶端开始 (转)

在ios8上 [TableView setSeparatorInset:UIEdgeInsetsMake(0,0,0,0)];不起作用

经过测试加入下面方法 在ios7 8上都可以正常工作
    -(void)viewDidLayoutSubviews  
    {  
        if ([self.tableView respondsToSelector:@selector(setSeparatorInset:)]) {  
            [self.tableView setSeparatorInset:UIEdgeInsetsMake(0,0,0,0)];  
        }  
          
        if ([self.tableView respondsToSelector:@selector(setLayoutMargins:)]) {  
            [self.tableView setLayoutMargins:UIEdgeInsetsMake(0,0,0,0)];  
        }  
    }  
      
    -(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];  
        }  
    }  

 


对于多余的横线,如果显示不到全屏,会出现横线。

只需要设置为 

UITableViewStyleGrouped

 

相关文章:

  • 2022-12-23
  • 2021-05-17
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2021-12-27
  • 2022-01-11
  • 2022-12-23
猜你喜欢
  • 2022-12-23
  • 2021-05-22
  • 2022-12-23
  • 2022-12-23
  • 2021-07-03
  • 2022-12-23
  • 2022-12-23
相关资源
相似解决方案