配件动作segue(UITableViewController)

我试图让通过IB的segue,切换视图时按tableView中的单元格附件。

来自我的IB的图像:

1.从tableviewcontroller的单元格拖到另一个视图并selectAccessory Action – > push

IB截图

当我运行我的项目时,我得到错误:

[setValue:forUndefinedKey:]:这个类不是关键的值,它的关键是accessoryActionSegueTemplate

我认为这可能是单元格的重用标识符错误。

我的cellForRowAtIndexPath:方法:

 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; 

我可以使用performSegueWithIdentifier:方法来解决这个问题,但我想弄清楚为什么我在IB中有配件操作的问题。

我有这个问题时,我已经从原型细胞的细节附件button,按住Ctrl键拖动到下一个视图控制器。 所以相反,我做了从表视图控制器本身的拖动,并添加了一些代码。

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)) } 

这适用于iOS 5.0 – 10.x

当我在iPod Touch上运行iOS 5上的应用程序而不是在iPhone 5上的iOS 6上运行应用程序时,出现此错误。

文档说,辅助操作在iOS 3.0中被弃用。 这个错误似乎是在iOS 6中显示和允许的。

你能确认你正在testing的iOS版本吗?

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

我遇到了同样的问题。 在iOS 6上运行良好,在5.1上崩溃。

我解决这个问题的方法是使用一个标准的UITableViewCell并创build一个UIButton的附件button,在其上放置一个Segue。

在iOS 5.x中,当您在故事板中创buildpopup窗口样式时,也会发生此错误,并且(在我的情况下)将其锚定到UITableViewCell。

在这种情况下,错误信息是一个完全误导的红色鲱鱼。

我假设iOS 5.x不支持锚定的popover segues。

将navigationController从对象库拖到storyboard文件中,并尝试这样做,它应该可以工作。下一个View应该有导航控制器。