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);ios

        if(cell == nil){spa

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

   }xml

     if(cell!.respondsToSelector("setLayoutMargins:")){
        cell!.layoutMargins=UIEdgeInsetsZero
     }
     if(cell!.respondsToSelector("setSeparatorInset:")){
         cell!.separatorInset=UIEdgeInsetsZero;
     }
  return cell!
}
这样不出意外的话,Table的分割线就没有空白间距了。
相关文章
相关标签/搜索