zoukankan      html  css  js  c++  java
  • ios8 UITableView设置 setSeparatorInset:UIEdgeInsetsZero不起作用的解决办法

    在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];
    
    }

    这样,空白就没有了

  • 相关阅读:
    牛逼的博客地址
    动画的keyPath
    跳转到系统设置的各种配置
    UITextField只允许输入正数
    冒泡排序
    number类型的数组
    正则表达式
    C中常用的数学函数
    利用运行时,查看一个类的所有子类
    玉蟾宫(悬线法)
  • 原文地址:https://www.cnblogs.com/hero11223/p/5174794.html
Copyright © 2011-2022 走看看