在我的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