views:

195

answers:

1

I have a tableView. Everything it set up and working. I had cell.accessoryType working fine, but not once have I gotten cell.editingAccessoryType to work. It worked with that deprecated method, but with the new one...no luck. Here's my code, at least for the first section:

- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {
UITableViewCell *cell = nil;

switch (indexPath.section) {
case RFE_SECTION: switch (indexPath.row) { case 0: { static NSString *RFECellIdentifier = @"RFECellIdentifier";

cell = [tableView dequeueReusableCellWithIdentifier:RFECellIdentifier];

if (cell == nil) 
{
 // Create a cell to display "Add Visit".
 cell = [[[UITableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:RFECellIdentifier] autorelease];
 cell.textLabel.lineBreakMode = UILineBreakModeWordWrap;
 cell.textLabel.numberOfLines = 0;
 cell.textLabel.font = [UIFont fontWithName:@"American Typewriter" size:16.0f];
}
if (visit.rfe.length == 0) 
{
 cell.textLabel.text = @"Add Reason for Encounter";
}
if (visit.rfe.length != 0) 
{
 cell.textLabel.text = visit.rfe;
}

} break; } break;

Next section, etc, etc, etc.

Whenever i put the editingAccessoryType in, I go to edit the tableView and it doesn't show up. Any ideas? Am I missing some delegate method or something?

I also have a - (void)setEditing:(BOOL)editing animated:(BOOL)animated method set up. Would that make a difference? I'm kinda lost right now. Thanks in advance.

+1  A: 

Given that you reuse cells, make sure you set both accessoryType and editingAccessoryType for each cell and comment out -tableView:accessoryTypeForRowWithIndexPath:. If nothing happens, comment out all your cell setup code in -tableView:cellForRowAtIndexPath:, returning an empty cell with an accessory.

Costique
I did all that.Reduced my method to the simplest terms.- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath { static NSString *RFECellIdentifier = @"RFECellIdentifier"; UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:RFECellIdentifier]; if (cell == nil) { // Create a cell to display "Add Visit". cell = [[[UITableViewCell alloc] init] autorelease]; } cell.accessoryType = UITableViewCellAccessoryDisclosureIndicator; cell.editingAccessoryType = UITableViewCellAccessoryNone; return cell;}Still no dice
monotreme
Also, I'm not using a UITableViewController@interface VisitDetailViewController : UIViewController <UITableViewDelegate, UITableViewDataSource, UINavigationControllerDelegate> Am I missing anything here?
monotreme
setting cell.editingAccessoryType to UITableViewCellAccessoryNone *hides* the accessory while editing, which explains why you don't see any on entering editing state. That is the expected behaviour. Try setting it to any other value just to make sure it works.
Costique