在我的tableview中,我使用背景图像作为我的细胞(完全黑色的图像),我也想在我的细胞中使用附件指示器。在细胞的属性窗口,我设置AccessoryDisclosureIndicatorios - tableview附件指示器未显示
在我的.m文件,我把这些代码的实现代码如下:
- (UITableViewCellAccessoryType)tableView:(UITableView *)tableView accessoryTypeForRowWithIndexPath:(NSIndexPath *)indexPath{
return UITableViewCellAccessoryDisclosureIndicator;
}
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
static NSString *CellIdentifier = @"Cell";
UITableViewCell *cell = (UITableViewCell *) [tableView dequeueReusableCellWithIdentifier:CellIdentifier];
if (cell == nil) {
cell = [[UITableViewCell alloc] initWithStyle:UITableViewCellStyleSubtitle reuseIdentifier:CellIdentifier];
cell.backgroundColor = [UIColor clearColor];
}
cell.textLabel.backgroundColor=[UIColor clearColor];
cell.textLabel.text=[arrMagaza objectAtIndex:indexPath.row];
cell.textLabel.textColor=[UIColor whiteColor];
NSString *distance=[arrDistance objectAtIndex:indexPath.row];
cell.detailTextLabel.backgroundColor=[UIColor clearColor];
cell.detailTextLabel.textColor=[UIColor whiteColor];
cell.detailTextLabel.text=[distance stringByAppendingFormat:@" km"];
cell.accessoryType=UITableViewCellAccessoryDisclosureIndicator;
return cell;
}
- (void) tableView:(UITableView *)tableView willDisplayCell:(UITableViewCell *)cell forRowAtIndexPath:(NSIndexPath *)indexPath {
cell.backgroundView = [[UIImageView alloc] initWithImage:[UIImage imageNamed:@"tablecell.png"]];
tableView.backgroundColor=[UIColor blackColor];
tableView.separatorColor= [UIColor clearColor];
cell.accessoryType=UITableViewCellAccessoryDisclosureIndicator;
}
但是当我运行应用程序的辅助指标不是在视图中显示。 我做错了什么?是关于我用于细胞的背景图像的问题吗?
请发布添加图片的代码 –
如何设置单元格的背景图片?你的代码是好的我认为这个问题是你通过指标绘制图像。删除backgorund图片只是为了测试。并且你不应该在单元格的backgorund颜色上有清晰的颜色,这将以低速滚动速度结束 –
感谢您的建议我删除该代码 – ercan