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

查看:162
本文介绍了有没有办法让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;
}

注意:包括 layoutMargins separatorInset ,以支持两个iOS版本

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

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

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