zoukankan      html  css  js  c++  java
  • ios8 UITableView设置 setSeparatorInset:UIEdgeInsetsZero不起作用的解决办法(去掉15px空白间距)

    但是在ios8中,设置setSeparatorInset:UIEdgeInsetsZero 已经不起作用了。下面是解决办法:
    首先在viewDidLoad方法加入以下代码:
    if(leftTable!.respondsToSelector("setLayoutMargins:")){
         leftTable?.layoutMargins=UIEdgeInsetsZero
    }
    if(leftTable!.respondsToSelector("setSeparatorInset:")){
         leftTable!.separatorInset=UIEdgeInsetsZero;
    }
    然后在UITableView的代理方法中加入以下代码:
    func tableView(tableView: UITableView, cellForRowAtIndexPath indexPath: NSIndexPath) -> UITableViewCell {
       let Identifier="MultilevelTableViewCell";

            var cell=tableView.dequeueReusableCellWithIdentifier(Identifier);

            if(cell == nil){

        cell=UITableViewCell(style: UITableViewCellStyle.Default, reuseIdentifier:Identifier)

       }

         if(cell!.respondsToSelector("setLayoutMargins:")){
            cell!.layoutMargins=UIEdgeInsetsZero
         }
         if(cell!.respondsToSelector("setSeparatorInset:")){
             cell!.separatorInset=UIEdgeInsetsZero;
         }
      return cell!
    }
    这样不出意外的话,Table的分割线就没有空白间距了。
  • 相关阅读:
    小毛驴基本语法
    文本数据IO操作--字符流
    基本IO操作--字节流
    文件指针操作
    文件操作——RandomAccessFile
    Java文件操作——File
    前端修炼-javascript关键字之prototype
    Redux介绍及基本应用
    IOS应用程序生命周期
    EF 只更新部分字段
  • 原文地址:https://www.cnblogs.com/brance/p/5197928.html
Copyright © 2011-2022 走看看