zoukankan      html  css  js  c++  java
  • UITableViewCell左侧会有默认15像素的空白

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

           }

    }

  • 相关阅读:
    「考试」省选6
    「考试」省选5
    「考试」省选4
    「笔记」拉格朗日插值
    数学专测
    「笔记」$exlucas$
    「总结」$dp1$
    「总结」达哥数学专项
    「总结」筛法2
    「总结」莫反2
  • 原文地址:https://www.cnblogs.com/fanwenzheIOS/p/5115789.html
Copyright © 2011-2022 走看看