仅删除一个单元格的分隔线 [英] Remove separator line for only one cell
本文介绍了仅删除一个单元格的分隔线的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我正在尝试删除一个 UITableViewCell
的分隔符。我做了以下:
I'm trying to remove the separator for one UITableViewCell
. I did the following:
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
UITableViewCell *cell;
cell = [super tableView:tableView cellForRowAtIndexPath:indexPath];
if (indexPath.row == 1)
cell.separatorInset = UIEdgeInsetsZero;
return cell;
}
(这是静态单元格
。)当我运行应用程序时。分隔线仍在那里。如何删除一个单元格的分隔线
?
(It's static cells
.) When I run the app. The separator line is still there. How can I remove the separator line for one cell
?
推荐答案
开你需要使用iOS 8:
On iOS 8 you need to use:
cell.layoutMargins = UIEdgeInsetsZero
如果你想与iOS 7兼容,你应该这样做:
If you want to be compatible with iOS 7 as well you should do following:
if ([cell respondsToSelector:@selector(setSeparatorInset:)]) {
[cell setSeparatorInset:UIEdgeInsetsZero];
}
if ([cell respondsToSelector:@selector(setLayoutMargins:)]) {
[cell setLayoutMargins:UIEdgeInsetsZero];
}
ADD:如果以前不起作用 - 用这个。 (来自下面的答案)
ADD: If previous didn't work - use this. (from answer below)
cell.separatorInset = UIEdgeInsetsMake(0, 1000, 0, 0);
这篇关于仅删除一个单元格的分隔线的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文