在iOS中使用背景图像时,需要删除UITableView中单元格之间的边框
我在删除我的在iOS中使用背景图像时,需要删除UITableView中单元格之间的边框,ios,uitableview,Ios,Uitableview,我在删除我的UITableView中每个单元格之间出现的白色边框时遇到问题。我试过使用: [myTableView setSeparatorStyle:UITableViewCellSeparatorStyleNone]; 在我的viewDidLoad方法中,但不幸的是,这似乎不起作用。我正在使用一个背景图像来显示我的单元格,我希望删除这些图像之间的边界。图像本身是每个单元格的大小,以及我在我的CustomTableViewCell类中设置的每个单元格的大小,如下所示: self.conten
UITableView
中每个单元格之间出现的白色边框时遇到问题。我试过使用:
[myTableView setSeparatorStyle:UITableViewCellSeparatorStyleNone];
在我的viewDidLoad
方法中,但不幸的是,这似乎不起作用。我正在使用一个背景图像来显示我的单元格,我希望删除这些图像之间的边界。图像本身是每个单元格的大小,以及我在我的CustomTableViewCell
类中设置的每个单元格的大小,如下所示:
self.contentView.frame = CGRectMake(0, 0, 320, 80);
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
static NSString *CellIdentifier = @"mycell";
MyTableViewCell *cell = (MyTableViewCell *)[tableView dequeueReusableCellWithIdentifier:CellIdentifier];
if (cell == nil) {
cell = [[MyTableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:CellIdentifier];
cell.selectionStyle = UITableViewCellSelectionStyleNone;
}
cell.ID.text = [[DataModel sharedInstance].ID objectAtIndex:indexPath.row];
cell.Name.text = [[DataModel sharedInstance].Name objectAtIndex:indexPath.row];
cell.Date.text = [[DataModel sharedInstance].Date objectAtIndex:indexPath.row];
[cell setBackgroundView:[[UIImageView alloc] initWithImage:[UIImage imageNamed:@"Cell.png"]]];
return cell;
}
我的cellforrowatinexpath
方法如下:
self.contentView.frame = CGRectMake(0, 0, 320, 80);
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
static NSString *CellIdentifier = @"mycell";
MyTableViewCell *cell = (MyTableViewCell *)[tableView dequeueReusableCellWithIdentifier:CellIdentifier];
if (cell == nil) {
cell = [[MyTableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:CellIdentifier];
cell.selectionStyle = UITableViewCellSelectionStyleNone;
}
cell.ID.text = [[DataModel sharedInstance].ID objectAtIndex:indexPath.row];
cell.Name.text = [[DataModel sharedInstance].Name objectAtIndex:indexPath.row];
cell.Date.text = [[DataModel sharedInstance].Date objectAtIndex:indexPath.row];
[cell setBackgroundView:[[UIImageView alloc] initWithImage:[UIImage imageNamed:@"Cell.png"]]];
return cell;
}
不管我做了什么,我都能看到我在桌子上的细胞之间有一条清晰的白色边界。我真的想删除这个。有人知道我做错了什么吗?在viewDidLoad中设置UITableView Separator颜色可能太早了。请尝试将视图改为显示。在界面生成器内部-将分隔符更改为“无”,然后将分隔符颜色更改为“清除颜色”:
试试[self.tableView setSeparatorColor:[UIColor clearColor]];这是分组表视图吗?感谢您的及时回复@约翰:我在viewDidLoad方法中尝试了这一行,得到了相同的结果。@MishieMoo,我的表没有分组。我想知道是否应该明确设置背景图像的边框?