有没有办法让 iOS 7 中的 UITableView 单元格在分隔符中没有换行符? [英] Is there a way to make UITableView cells in iOS 7 not have a line break in the separator?

查看:34
本文介绍了有没有办法让 iOS 7 中的 UITableView 单元格在分隔符中没有换行符?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我注意到在 iOS 7 中,UITableViewCells 在单元格的分隔符中有一个换行符,而 iOS 6 没有.有没有办法摆脱这个换行符?将分隔符更改为无,然后使用分隔符的颜色制作 UIViews 仍然会导致无论如何出现白色分隔符.

I noticed that in iOS 7, UITableViewCells have a line break in the separator of the cell that iOS 6 does not have. Is there a way to get rid of this line break? Changing the separator to none and then making UIViews with the color of the separator still causes the white separator to occur regardless.

推荐答案

对于 iOS7:

if ([self.tableView respondsToSelector:@selector(setSeparatorInset:)]) {
    [self.tableView setSeparatorInset:UIEdgeInsetsZero];
}

对于 iOS8:

首先按如下方式配置您的表格视图:

First configure your table view as follows:

if ([self.tableView respondsToSelector:@selector(layoutMargins)]) {
    self.tableView.layoutMargins = UIEdgeInsetsZero;
}

然后在您的 cellForRowAtIndexPath: 方法中,按如下方式配置单元格:

Then in your cellForRowAtIndexPath: method, configure the cell as follows:

if ([cell respondsToSelector:@selector(layoutMargins)]) {
    cell.layoutMargins = UIEdgeInsetsZero;
}

注意:同时包含 layoutMarginsseparatorInset,以支持两个 iOS 版本

Note: Include both layoutMargins and separatorInset, to support both iOS versions

这篇关于有没有办法让 iOS 7 中的 UITableView 单元格在分隔符中没有换行符?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆