您的位置:首页 > 移动开发 > Swift

Swift tableview 单元格分割线显示不全的解决方法

2015-08-30 19:50 711 查看
今天写代码初次遇到这个问题:



查阅了资料后解决方法如下:

在viewdidload()中加入下面代码:

if aboutTable.respondsToSelector("setSeparatorInset:"){
aboutTable.separatorInset = UIEdgeInsetsZero
}
if aboutTable.respondsToSelector("setLayoutMargins:"){
aboutTable.layoutMargins = UIEdgeInsetsZero
}


然后重写方法:

func tableView(tableView: UITableView, willDisplayCell cell: UITableViewCell, forRowAtIndexPath indexPath: NSIndexPath) {
if cell.respondsToSelector("setLayoutMargins:"){
cell.layoutMargins = UIEdgeInsetsZero
}
if cell.respondsToSelector("setSeparatorInset:"){
cell.separatorInset = UIEdgeInsetsZero
}
}


问题解决:

内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: