【问题标题】:Hiding UITableView separator behind the contentView在 contentView 后面隐藏 UITableView 分隔符
【发布时间】:2009-09-16 01:05:01
【问题描述】:

我在 iPhone OS 3.0 中创建了一个类似于左图的分组 UITableView。结果是 OS 3.1 中的正确图像。

imageView 位于分隔符下方。

我尝试将内容视图放在前面。当 tableView 处于分组样式(自己绘制分隔符)时,separatorStyle 的适当性似乎被忽略了。更改分隔符颜色会给出字符串结果。

感谢您的帮助!

编辑:这是没有更改的代码:

static NSString *CellIdentifier = @"Cell";

UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier];
if (cell == nil) {
    cell = [[[UITableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:CellIdentifier] autorelease];
    cell.accessoryType = UITableViewCellAccessoryDisclosureIndicator;
    cell.textLabel.font = [UIFont boldSystemFontOfSize:18.0];
}

cell.textLabel.text = [[metro.arretDirection objectAtIndex:indexPath.row] name];

NSString* name;
if (indexPath.row == 0) {
    name = @"Begining";
}
else if (indexPath.row + 1 == [metro.arretDirection count]) {
    name = @"End";
}
else {
    if ([[[metro.arretDirection objectAtIndex:indexPath.row] lines] count]== 1) name = @"Little";
    else name = @"Big";
}

UIImage* metroImage = [[UIImage alloc] initWithContentsOfFile:[[[NSBundle mainBundle] resourcePath] stringByAppendingPathComponent:[NSString stringWithFormat:@"%i%@.png", metro.metroNumber, name]]];
cell.imageView.image = metroImage;
[metroImage release];

return cell;

【问题讨论】:

  • 这很好奇。可以发一下相关代码吗?

标签: iphone cocoa-touch uitableview separator


【解决方案1】:

在单元格上尝试将 clipsToBounds 设置为 NO。例如cell.clipsToBounds = NO;

【讨论】:

  • 有可能是3.1中imageView的大小缩小了2个像素,所以把imageView的frame写到log里看看是什么意思。还可以查看 3.0 中 imageView 的 contentMode 是什么以及它与 3.1 的比较,还可以尝试 imageView 的 clipsToBounds 属性。甚至可能是 imageView 层的 masksToBounds 属性(尽管这应该已经设置为 no)。
【解决方案2】:

答案其实很简单,只需在单元格中添加一个UIImageView 并正确放置即可,而不是使用内置的imageView。

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2015-11-05
    • 2015-10-04
    • 1970-01-01
    • 1970-01-01
    • 2020-10-21
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多