17
votes

I'm trying to make segue via IB, that switching views when pressed cell accessory in tableView.

Images from my IB:

1.I'm dragging from cell of tableviewcontroller to another view and selecting Accessory Action -> push

IB screenshot

and when i'm running my project i get error:

[ setValue:forUndefinedKey:]: this class is not key value coding-compliant for the key accessoryActionSegueTemplate

I think that this might be something wrong with reuseIdentifier of cell.

My cellForRowAtIndexPath: method:

static NSString *CellIdentifier = @"champion cell";
UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier];

NSString *cellIconName = ((championList *)[self.champions objectAtIndex:indexPath.row]).championImage;
UIImage *cellIcon = [UIImage imageNamed:cellIconName];
[[cell imageView] setImage:cellIcon];

cell.imageView.frame = CGRectMake(0.0f, 0.0f, 70.0f, 70.0f);

cell.imageView.layer.cornerRadius = 7;
[cell.imageView.layer setMasksToBounds:YES];

cell.textLabel.text = ((championList *) [self.champions objectAtIndex:indexPath.row]).championName;
cell.detailTextLabel.text = ((championList *) [self.champions objectAtIndex:indexPath.row]).championId;

return cell;

I can use performSegueWithIdentifier: method as solution of this problem, but i want to figure out why i having problem with accessory action in IB.

5
Strange bug! Xcode help found nothing for the search key "accessoryActionSegueTemplate" and google also found nothing...Stas
I think that is's some kind of apple bug. Hope they fix it soon..Stas
What version of iOS are you using? My app was originally written for iOS 6 but a last minute decision change required me to back port it to iOS 5. After doing this I started to encounter this error. This isn't necessarily the answer you're looking for but this issue appears to be limited to iOS 5 as the same code works fine on iOS 6.Brian Antonelli
yep, my app is also originally written for iOS 6 and then ported to iOS 5ignotusverum

5 Answers

27
votes

I had this problem when I had ctrl-dragged a segue from the detail accessory button of the prototype cell to the next view controller. So instead I did the drag from the table view controller itself, and added a bit of code to it.

Objective-C:

- (void)tableView:(UITableView *)tableView accessoryButtonTappedForRowWithIndexPath:(NSIndexPath *)indexPath
{
    [self performSegueWithIdentifier: @"EditUser" sender: [tableView cellForRowAtIndexPath: indexPath]];
}

Swift 3.0:

func tableView(_ tableView: UITableView, accessoryButtonTappedForRowWith indexPath: IndexPath) {
    performSegue(withIdentifier: "EditUser", sender: tableView.cellForRow(at: indexPath))
}

This works for iOS 5.0 - 10.x

2
votes

I'm getting this error when I run my application on iOS 5 on an iPod Touch and not on iOS 6 on an iPhone 5.

The docs say that accessory action was deprecated in iOS 3.0. The bug seems to be that it's being shown and allowed in iOS 6.

Can you confirm what version of iOS you're testing against?

https://developer.apple.com/library/ios/#documentation/UIKit/Reference/UITableViewCell_Class/DeprecationAppendix/AppendixADeprecatedAPI.html#//apple_ref/occ/instp/UITableViewCell/accessoryAction

1
votes

I just ran into the same problem. Works fine on iOS 6, crashes on 5.1.

The way I solved it is by using a standard UITableViewCell and creating the accessory button out of a UIButton, on which I put a segue.

1
votes

On iOS 5.x, this error also occurs when you create a popover style segue in a storyboard, and (in my case) anchor it to a UITableViewCell.

In this case, the error message is a completely misleading red herring.

I'm assuming that iOS 5.x doesn't support anchored popover segues.

-2
votes

Drag a navigationController from object library to your storyboard file and try to do this, it should work.Your next View should have the navigation controller.