zoukankan      html  css  js  c++  java
  • iOS8 解决tableview分割线缺少的15像素

    原文:http://blog.csdn.net/lengshengren/article/details/19335637

    在ios7中,UITableViewCell左侧会有默认15像素的空白。这时候,设置setSeparatorInset:UIEdgeInsetsZero 能将空白去掉。

    但是在ios8中,设置setSeparatorInset:UIEdgeInsetsZero 已经不起作用了。下面是解决办法

    首先在viewDidLoad方法加入以下代码:

     if ([self.tableView respondsToSelector:@selector(setSeparatorInset:)]) {

    [self.tableView setSeparatorInset:UIEdgeInsetsZero];

    }

    if ([self.tableView respondsToSelector:@selector(setLayoutMargins:)]) {

    [self.tableView setLayoutMargins:UIEdgeInsetsZero];

    }

    然后在UITableView的代理方法中加入以下代码

    - (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];

    }

    }

  • 相关阅读:
    牛客(4) 重建二叉树
    牛客(3)从尾到头打印链表
    牛客(2)字符串替换
    牛客(1)二分查找
    同义词+序列+视图+临时表
    用户+授权
    控制文件+日志文件
    oracle表的基本操作
    Linux(CentOS6.8)配置Redis
    Linux(CentOS6.8)配置ActiveMQ
  • 原文地址:https://www.cnblogs.com/JJFly/p/4312773.html
Copyright © 2011-2022 走看看