iOS   发布时间:2022-05-04  发布网站:大佬教程  code.js-code.com
大佬教程收集整理的这篇文章主要介绍了iphone – 附件动作segue(UITableViewController)大佬教程大佬觉得挺不错的,现在分享给大家,也给大家做个参考。

概述

我试图通过IB做segue,当在tableView中按下单元格附件时切换视图。 我的IB图片: 1.我从tableviewcontroller的单元格拖动到另一个视图,然后选择Accessory Action – >推 当我运行我的项目我得到错误: [ SETVALue:forUndefinedKey:]: this class is not key value coding-compliant
我试图通过IB做segue,当在tableView中按下单元格附件时切换视图。

我的IB图片

1.我从tableviewcontroller的单元格拖动到另一个视图,然后选择Accessory Action – >推

当我运行我的项目我得到错误

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

我的cellForRowATindexPath:@L_673_4@:

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:@L_673_4@来解决这个问题,但是我想知道为什么我在IB中遇到了附件动作问题。

解决方法

当我将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

大佬总结

以上是大佬教程为你收集整理的iphone – 附件动作segue(UITableViewController)全部内容,希望文章能够帮你解决iphone – 附件动作segue(UITableViewController)所遇到的程序开发问题。

如果觉得大佬教程网站内容还不错,欢迎将大佬教程推荐给程序员好友。

本图文内容来源于网友网络收集整理提供,作为学习参考使用,版权属于原作者。
如您有任何意见或建议可联系处理。小编QQ:384754419,请注明来意。