iOS7 iOS8 tableview separatorInset cell分割线左对齐

iOS7 和 iOS8 中tableview cell分割线左对齐的方法不一样,特此为以后需要做笔记。

iOS7 中方法很简单,只需要设置 _table.separatorInset = UIEdgeInsetsMake(0, 0, 0, 0);

而iOS8 中方法需要写一段代码:

-(void)viewDidLayoutSubviews {
    if ([_table respondsToSelector:@selector(setSeparatorInset:)]) {
        [_table setSeparatorInset:UIEdgeInsetsZero];
    }
    if ([_table respondsToSelector:@selector(setLayoutMargins:)])  {
        [_table setLayoutMargins:UIEdgeInsetsZero];
    }
}

-(void)tableView:(UITableView *)tableView willDisplayCell:(UITableViewCell *)cell forRowAtIndexPath:(NSIndexPath *)indexPath{

       if ([cell respondsToSelector:@selector(setLayoutMargins:)]) {
           [cell setLayoutMargins:UIEdgeInsetsZero];
       }
       if ([cell respondsToSelector:@selector(setSeparatorInset:)]){
            [cell setSeparatorInset:UIEdgeInsetsZero];
       }

}

  

时间: 2024-07-29 05:48:56

iOS7 iOS8 tableview separatorInset cell分割线左对齐的相关文章

iOS8 tableview separatorInset cell分割线左对齐,ios7的方法失效了

2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 -(void)viewDidLayoutSubviews { if ([self.mytableview respondsToSelector:@selector(setSeparatorInset:)]) { [self.mytableview setSeparatorInset:UIEdgeInsetsZero]; } if ([self.mytableview respondsToSelect

ios8 ios7 tableview cell 分割线左对齐

ios8中左对齐代码 //加入如下代码 -(void)tableView:(UITableView *)tableView willDisplayCell:(UITableViewCell *)cell forRowAtIndexPath:(NSIndexPath *)indexPath{ if ([tableView respondsToSelector:@selector(setSeparatorInset:)]) { [tableView setSeparatorInset:UIEdgeI

六、UITableView表的分割线左对齐

//分割线左对齐 -(void)tableView:(UITableView *)tableView willDisplayCell:(UITableViewCell *)cell forRowAtIndexPath:(NSIndexPath *)indexPat{ if ([cell respondsToSelector:@selector(setLayoutMargins:)]) { [cell setLayoutMargins:UIEdgeInsetsZero]; } if ([cell

iOS 8 UITableView 的分割线左对齐

1. 解决UITableView分割线距左边有距离的问题 我们在使用tableview时会发现分割线的左边会短一些,通常可以使用setSeparatorInset:UIEdgeInsetsZero 来解决.但是升级到XCode6之后,在iOS8里发现没有效果.下面给出解决办法: viewDidLoad方法和willDisplayCell中加上如下代码: if ([self.tableView respondsToSelector:@selector(setSeparatorInset:)]) {

iOS 8 UITableViewCell 分割线 左对齐

//加入如下代码 -(void)tableView:(UITableView *)tableView willDisplayCell:(UITableViewCell *)cell forRowAtIndexPath:(NSIndexPath *)indexPath{          if ([tableView respondsToSelector:@selector(setSeparatorInset:)]) {         [tableView setSeparatorInset:U

iOS8 tableView的Cell高度自适应开发

1.在- (void)viewDidLoad中设置: //预计高度为81 self.tableView.estimatedRowHeight = 81.0f; //自适应高度 self.tableView.rowHeight = UITableViewAutomaticDimension; 2.XIB自定义的Cell的autoLayout的时候注意自适应的内容的Label或者TextField等等的约束. 3.当然不需要实现设置高度的方法了. - (CGFloat)tableView:(UITa

iOS中 自定义cell分割线/分割线偏移 韩俊强的博客

在项目开发中我们会常常遇到tableView 的cell分割线显示不全,左边会空出一截像素,更有甚者想改变系统的分割线,并且只要上下分割线的一个等等需求,今天重点解决以上需求,仅供参考: 每日更新关注:http://weibo.com/hanjunqiang  新浪微博! 1.cell 分割线不全: 解决方案1: 补全分割线 -(void)viewDidLayoutSubviews { if ([_listTableView respondsToSelector:@selector(setSep

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

IOS8 设置TableView Separatorinset 分割线从边框顶端开始 在ios8上 [TableView setSeparatorInset:UIEdgeInsetsMake(0,0,0,0)];不起作用 经过测试加入下面方法 在ios7 8上都可以正常工作 -(void)viewDidLayoutSubviews{    if ([self.tableView respondsToSelector:@selector(setSeparatorInset:)]) {       

[iOS]技巧集锦:UITableView自定义Cell中的控件无法完全对齐Cell的左边界和右边界

这是个很诡异的问题,由于一些特殊需求,我的TableView的Cell的背景色是透明,其中的控件会有背景色,第一个控件和最后一个控件我都用IB自动设了约束,对齐Cell的左边界和右边界,但是自动约束很奇怪的是值都是-8(上下左右都是这个值).一开始并没在意因为显示出来是好的,但是不记得升级SDK到8.2还是8.3开始,左右就会多出空白来. 经过各种尝试,找到了解决方法.将左右的约束中item的related to margin(印象中是这么拼)取消勾选,值设为0就好了. 下班了等人,mac关了没