设为首页 加入收藏

TOP

ios8 UITableView设置 setSeparatorInset:UIEdgeInsetsZero不起作用的解决办法(去掉15px空白间距)
2017-10-10 12:16:37 】 浏览:6695
Tags: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的分割线就没有空白间距了。
】【打印繁体】【投稿】【收藏】 【推荐】【举报】【评论】 【关闭】 【返回顶部
上一篇Mac 通过gem安装CocoaPods及Pod的.. 下一篇swift基本运算符

最新文章

热门文章

Hot 文章

Python

C 语言

C++基础

大数据基础

linux编程基础

C/C++面试题目