Hiding UITableView separator behind the contentView

倾然丶 夕夏残阳落幕 提交于 2019-12-05 03:01:11

问题


I made a grouped UITableView in iPhone OS 3.0 that looked like the left image. The result is the right image in OS 3.1.

The imageView is under the separators.

I've tried to put the content view in front. The separatorStyle propriety seems ignored when the tableView is in grouped style (to draw the separator myself). Changing the separator color gives strings results.

Thanks for your help!

Edit: This is the code with no change made :

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;

回答1:


On the cell try setting clipsToBounds to NO. eg cell.clipsToBounds = NO;




回答2:


The answer was actually quite simple, simply add an UIImageView in the cell an place it properly instead of using the built in imageView.



来源:https://stackoverflow.com/questions/1430404/hiding-uitableview-separator-behind-the-contentview

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!