开发者

UITableViewCell cell.editingAccessoryType not working

开发者 https://www.devze.com 2022-12-17 18:36 出处:网络
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.

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)开发者_Python百科animated method set up. Would that make a difference? I'm kinda lost right now. Thanks in advance.


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.


make sure you don't set cell.editing=YES; seems intuitive, but messes up the whole works.

0

精彩评论

暂无评论...
验证码 换一张
取 消