我有一个自定义UITableViewCell
。这些有以下问题:用户界面问题与定制UITableViewCell
- 删除按钮太右,重叠我的背景。我想设置一个插图,以便它向左移动一点,然后看起来很棒。
蓝色的高亮显示状态横跨屏幕的整个宽度,我想它只是我的曲格背景的边界内进行设置。
有没有办法来解决这两个问题?谢谢。
编辑:我的代码如下设置背景(只是一个自定义的方法):
- (UIImage *)cellBackgroundForRowAtIndexPath:(NSIndexPath *)indexPath
{
NSInteger rowCount = [self tableView:[self tableView] numberOfRowsInSection:0];
NSInteger rowIndex = indexPath.row;
UIImage *background = nil;
if (rowIndex == 0) {
background = [UIImage imageNamed:@"cell_top.png"];
} else if (rowIndex == rowCount - 1) {
background = [UIImage imageNamed:@"cell_bottom.png"];
} else {
background = [UIImage imageNamed:@"cell_middle.png"];
}
return background;
}
我再打电话,只是得到的每一个细胞后更新它reloadTable
无效的方法在此方法中出现了行更新(添加或删除行,因为表中有3个不同的图像)。我也在调用结果控制器从Core Data获取所有项目并首次加载表格后调用此方法。
编辑2:这是reloadTable
方法的代码:
- (void)refreshTable
{
for (NSInteger j = 0; j < [self.tableView numberOfSections]; ++j)
{
for (NSInteger i = 0; i < [self.tableView numberOfRowsInSection:j]; ++i)
{
UIImage *background = [self cellBackgroundForRowAtIndexPath:[NSIndexPath indexPathForRow:i inSection:j]];
UIImageView *cellBackgroundView = [[UIImageView alloc] initWithImage:background];
cellBackgroundView.image = background;
UITableViewCell *cell = [self.tableView cellForRowAtIndexPath:[NSIndexPath indexPathForRow:i inSection:j]];
cell.backgroundView = cellBackgroundView;
}
}
}
的问题是:我不知道如何设置边距或一个的tableView的宽度或表视图细胞。我需要继承一些东西吗?它通常如何完成?
我相信这些问题都与你的“定制的'UITableViewCell'”的界限有关。你可以发布一些代码给我们看吗? –
@TheKraken我添加了一些代码,希望它有帮助。 – swiftcode
正确的图像被返回后,你是否将其设置为“UITableViewCell”的视图? –