当选择UITableView行时,是否调用prepareForSegue? [英] prepareForSegue not called when UITableView row selected?

查看:143
本文介绍了当选择UITableView行时,是否调用prepareForSegue?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我使用NSFetchedResultsController设置了一个UITableView,它显示了许多原型UITableViewCells。我已经从我的UITableViewCell连接了一个push segue到我的DetailViewController。

I have setup a UITableView using a NSFetchedResultsController that displays a number of prototype UITableViewCells. I have hooked up a push segue from my UITableViewCell to my DetailViewController.

在我的TableViewController中,我实现了两个:

In my TableViewController I have implemented both:

- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath {
    NSLog(@"%s", __PRETTY_FUNCTION__);
    [tableView deselectRowAtIndexPath:indexPath animated:YES];
}

- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
    NSLog(@"%s", __PRETTY_FUNCTION__);
}

当我运行应用程序并单击表格中的一行时,仅查看我的应用程序调用:

When I run the application and click on a row in the tableView my application only calls:

[TableViewController tableView:didSelectRowAtIndexPath:]
[TableViewController tableView:didSelectRowAtIndexPath:]
[TableViewController tableView:didSelectRowAtIndexPath:]

如果我删除segue并将其重新连接,形成一个UIBarButtonItem到DetailViewController然后segue被正确调用,任何人都可以想到我缺少的东西吗?

If I delete the segue and rewire it form a UIBarButtonItem to the DetailViewController then the segue is called correctly, can anyone think what I am missing?

已添加:

- (IBAction)tester:(id)sender {
    [self performSegueWithIdentifier:@"SEGTEST" sender:nil];
}

并将其连接到名为tester的UIButtonBarItem,它可以工作,我当我从UITableViewCell链接到控制器时,它仍然无法启动它。

and connected it unto a UIButtonBarItem that called "tester" and it works, I just can't get it to fire still when I link from the UITableViewCell to the controller.

推荐答案

经过一些挖掘我最终发现 UITableViewCell 标识符错误地设置为 CELL_ID ,当它应该是 PLANTCELL_ID

After a bit of digging I eventually found that the UITableViewCell identifier was set incorrectly to "CELL_ID" when it should have been "PLANTCELL_ID".

Som为其他人发现选择了 UITableViewCell a UITableView 不调用关联的segue,检查故事板和 tableView:cellForRowAtIndexPath中是否正确设置了您的单元标识符:

Som for anyone else who finds that selecting a UITableViewCell in a UITableView does not call the associated segue, check if your cell identifier is set correctly in both the storyboard and tableView:cellForRowAtIndexPath:.

这篇关于当选择UITableView行时,是否调用prepareForSegue?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆