2

我在alaUIImageView中放置了accessoryView一个:UITableViewCell

UIImage* dragHandleImage = [UIImage imageNamed:@"rtf_icon"];
UIImageView* dragHandleView = [[[UIImageView alloc] initWithImage:dragHandleImage] autorelease];

dragHandleView.tag = DRAG_HANDLE_TAG;
cell.accessoryView = dragHandleView;

但是,当单元格显示在表格中时,附件视图图像仅在每个部分的第一行可见。在四处摸索之后,我发现在 tableview 的willDisplayCell:委托调用和单元格的显示之间的某处,accessoryView 的 alpha 属性设置为零。有没有办法阻止这种情况,所以图像是可见的?

编辑:它似乎是在layoutSubviews调用UITableViewCell.

编辑:完整的cellForRowAtIndexPath:功能很长并且充满了在这个特定实例中不会被击中的案例。填充单元格的代码如下:

cell.textLabel.hidden = NO;
cell.textField.hidden = YES;
cell.textLabel.tag = indexPath.section * indexPath.row;
NSString *filename = document.document.filename;
if([filename isEqualToString:@""])
{
    filename = [document.document previewItemTitle];
}
cell.textLabel.text = filename;
cell.showsReorderControl = NO;  

当图像可见时,以下代码填充单元格:

cell.textField.tag = indexPath.section;
cell.textField.hidden = NO;
cell.textField.text = [section numberedTitle];
cell.textField.enabled = canAddSections;
cell.textField.clearButtonMode = UITextFieldViewModeWhileEditing;
cell.textField.contentVerticalAlignment = UIControlContentVerticalAlignmentCenter;
cell.textLabel.hidden = YES;
cell.showsReorderControl = NO;
4

1 回答 1

2

由于这些单元格是可编辑的,因此editingAccessoryView会显示。投入证明accessoryVieweditingAccessoryView解决问题。不优雅,但实用。

于 2012-07-11T17:54:28.517 回答