gpt4 book ai didi

ios - 带有图像背景的 iOS 7 中的 UITableViewCell 问题

转载 作者:行者123 更新时间:2023-11-28 22:16:00 25 4
gpt4 key购买 nike

当我将其背景设置为模式时,我在 iOS7 中遇到 UITableViewCell 的问题,即:

tableViewCell.backgroundView = 
[[UIImageView alloc] initWithImage:self.cellBackgroundImage];

当我这样做时,我关闭了表格 View 单元格分隔符,我仍然得到这个:

Bug example

每隔一行出现一条白线。即使我没有关闭分隔符,我仍然会在普通分隔符之上得到这条额外的线。这不会发生< iOS7。有谁知道如何解决这个问题?

最佳答案

-(void)viewDidLoad
{
self.tableView.separatorStyle = UITableViewCellSeparatorStyleNone;
self.tableView.rowHeight = self.cellBackgroundImage.size.height;
}

如果您仍然遇到问题,可能是您的 tableView 某处存在边界问题。你可以试一下 clipping to bounds 看看是否还有同样的问题:

- (UITableViewCell *)tableView:(UITableView *)tableView 
cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
static NSString *CellIdentifier = @"Cell";
UITableViewCell *cell =
[tableView dequeueReusableCellWithIdentifier:CellIdentifier
forIndexPath:indexPath];
// Is our layout bleeding into other cells? Let's see.
cell.clipsToBounds = YES;

cell.backgroundView =
[[UIImageView alloc] initWithImage:self.cellBackgroundImage];
// rest of code ...

return cell;
}

如果您的问题在裁剪后消失,您需要弄清楚您在布局中的哪个位置渗入了其他单元格。

关于ios - 带有图像背景的 iOS 7 中的 UITableViewCell 问题,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/21662522/

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