在tableview单元格中分配图像时,在tableview单元格之间获得间隙

时间:2011-12-09 07:32:55

标签: objective-c xcode

我已经创建了一个tableview并使用覆盖整个表格视图的图像自定义了tableview。一切正常但问题是我在相邻的tableview单元格之间得到了一个白色的间隙。甚至将tableview分隔符样式设置为null.but仍然无法删除两个相邻单元格之间的白板。下面是代码

enter image description here

用于分配表格视图图像的代码..

   - (void)viewDidLoad {
    [super viewDidLoad];
[self.tableview1 setSeparatorStyle:UITableViewCellSeparatorStyleNone];
[self.tableview1 setAllowsSelectionDuringEditing:TRUE];

    }

UIImage *image=[UIImage imageNamed:@"listy.png"];
UIImageView *imageView1=[[UIImageView alloc]initWithImage:image];
imageView1.contentMode=UIViewContentModeScaleToFill;
cell.backgroundView=imageView1;
[imageView1 release];



NSString *imagefile1 = [media1 objectAtIndex:indexPath.row]; 

NSString *escapedURL=[imagefile1 stringByAddingPercentEscapesUsingEncoding:NSASCIIStringEncoding];
mi.url=[NSURL URLWithString:escapedURL];
[objMan manage:mi];

cell.accessoryType=UITableViewCellAccessoryDisclosureIndicator;
cell.textLabel.text=[story objectAtIndex:indexPath.row];
cell.textLabel.backgroundColor=[UIColor clearColor];
cell.detailTextLabel.text=[descriptiondesc objectAtIndex:indexPath.row];
cell.detailTextLabel.backgroundColor=[UIColor clearColor];


return cell;



-(CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath    *)indexPath
{
return 77;
}

1 个答案:

答案 0 :(得分:0)

该教程中单元格的背景图像为320x84,尝试将行高改为84,或者调整图像大小,看看是否有任何改变。

enter image description here

如果您正在使用“标准”单元格,它从您的代码中查找(UITableViewCellStyleSubtitle),请尝试通过继承UITableViewCell创建自定义单元格,并在其中添加背景图像视图以及标签,就像它是在该教程中完成的,而不是使用标准单元格。

相关问题