gpt4 book ai didi

ios - 如何在静态单元格中隐藏单元格分隔符?

转载 作者:塔克拉玛干 更新时间:2023-11-02 10:00:28 26 4
gpt4 key购买 nike

我在 UITableView 中有自定义静态单元格,我想删除某些指定单元格 中的单元格分隔符。但是我如何以编程方式在静态单元格中执行此操作?

我的设备:iphone 5 iOS 7IOS模拟器:iphone 4s-iphone 6p,全部iOS 8.3

最佳答案

最好的办法可能是将表格的 separatorStyle 设置为 UITableViewCellSeparatorStyleNone 并在需要时手动添加/绘制一条线(可能在 tableView:cellForRowAtIndexPath: 中)。

这样使用,

...
if (cell == nil) {
cell = [[[UITableViewCell alloc] initWithStyle:UITableViewCellStyleSubtitle reuseIdentifier:CellIdentifier] autorelease];

// Drawing our own separatorLine here because I need to turn it off for the
// last row. I can only do that on the tableView and on on specific cells.
// The y position below has to be 1 less than the cell height to keep it from
// disappearing when the tableView is scrolled.
UIImageView *separatorLine = [[UIImageView alloc] initWithFrame:CGRectMake(0.0f, cell.frame.size.height - 1.0f, cell.frame.size.width, 1.0f)];
separatorLine.image = [[UIImage imageNamed:@"grayDot"] stretchableImageWithLeftCapWidth:1 topCapHeight:0];
separatorLine.tag = 4;

[cell.contentView addSubview:separatorLine];

[separatorLine release];
}

// Setup default cell setttings.
...
UIImageView *separatorLine = (UIImageView *)[cell viewWithTag:4];
separatorLine.hidden = NO;
...
// In the cell I want to hide the line, I just hide it.
seperatorLine.hidden = YES;

在ViewDidload中设置

self.tableView.separatorStyle = UITableViewCellSeparatorStyleNone; 

关于ios - 如何在静态单元格中隐藏单元格分隔符?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/31423077/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com