Reputation: 538
I placed a UIImageView
in for the accessoryView
in a UITableViewCell
ala:
UIImage* dragHandleImage = [UIImage imageNamed:@"rtf_icon"];
UIImageView* dragHandleView = [[[UIImageView alloc] initWithImage:dragHandleImage] autorelease];
dragHandleView.tag = DRAG_HANDLE_TAG;
cell.accessoryView = dragHandleView;
However, when the cell is displayed in the table, the accessoryView image is only visible on the first row in each section. After poking around, I found that somewhere between the tableview's willDisplayCell:
delegate call and the display of the cell, the accessoryView's alpha property is set to zero. Is there anyway to prevent this so the image is visible?
Edit:
It appears to be done during the layoutSubviews
call for the UITableViewCell
.
Edit:
The full cellForRowAtIndexPath:
function is long and full of cases that won't be hit in this particular instance. The code that populates the cell is below:
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;
The following code populates the cell when the image is visible:
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;
Upvotes: 2
Views: 2473
Reputation: 538
Since those cells are editable, the editingAccessoryView
gets shown. Putting the accessoryView
into the editingAccessoryView
proved to solve the issue. Inelegant, but functional.
Upvotes: 2