将UITableView分隔符隐藏在内容视图后面

3
我在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;

这很奇怪。你能否请发相关的代码? - coneybeare
2个回答

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

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

可能在3.1中imageView的大小缩小了2个像素,因此将imageView的frame写入日志并查看其内容。还要查看imageView在3.0中的contentMode以及与3.1的比较,尝试使用imageView的clipsToBounds属性。如果需要,还可以尝试使用imageView的layer的masksToBounds属性(尽管应该已经设置为no)。 - Jonathan.

网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接