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的分割线就没有空白间距了。
  • 相关阅读:
    scala-class
    uva-10422-骑士-搜索题
    HDU 5724
    HDU 5728
    CodeForces 414B
    CodeForces 698A
    Codeforces Round #363 (Div. 2)
    BestCoder 2nd Anniversary 1001 Oracle
    BestCoder 2nd Anniversary 1002 Arrange
    HDU 4798
  • 原文地址:https://www.cnblogs.com/brance/p/5197928.html
Copyright © 2011-2022 走看看