我在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;
有帮助吗?

解决方案 2

答案实际上非常简单,只需在单元格中正确添加 UIImageView ,而不是使用内置的imageView。

其他提示

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

许可以下: CC-BY-SA归因
不隶属于 StackOverflow
scroll top