代码之家  ›  专栏  ›  技术社区  ›  gcamp

在ContentView后面隐藏UITableView分隔符

  •  3
  • gcamp  · 技术社区  · 15 年前

    我在iPhoneOS3.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 回复  |  直到 13 年前
        1
  •  1
  •   Jonathan.    14 年前

    在单元上尝试设置 clipsToBounds 不同意 cell.clipsToBounds = NO;

        2
  •  1
  •   gcamp    13 年前

    答案其实很简单,只需添加一个 UIImageView 在单元中,一个适当的位置,而不是使用内置的ImageView。