简体   繁体   English

prepareForSegue:sender:永远不会被调用

[英]prepareForSegue:sender: is never called

I am following a tutorial for building a simple iOS application . 我正在遵循有关构建简单iOS应用程序教程

I am currently on the Displaying Information in the Detail Scene chapter. 我目前在“详细信息场景”一章中的显示信息”上

At the end it says I should now be able to run the application. 最后,它说我现在应该可以运行该应用程序了。 However, when I do run it and I click on a row in the master uitableview, it simply highlights blue but does not segue to the detail uitableview. 但是,当我运行它并单击主uitableview中的一行时,它只是突出显示了蓝色,但没有选择详细的uitableview。

So I put an NSLog in the prepareForSegue:sender: method and it is never called. 因此,我将NSLog放在prepareForSegue:sender:方法中,但从未调用过它。

Also, I do not remember telling Xcode (neither in the storyboard nor in any code) to segue when a row is pressed. 另外,我不记得告诉Xcode(在情节提要中还是在任何代码中)在按下一行时进行筛选。

Did I miss a part of the tutorial or did the tutorial leave something out? 我错过了本教程的一部分还是本教程遗漏了一些内容? Or did I just do a foolish mistake somewhere? 还是我只是在某个地方犯了一个愚蠢的错误? Please help me figure out how to activate the segue. 请帮助我弄清楚如何激活segue。

Thanks in advance! 提前致谢!

make sure these. 确保这些。

1) [self performSegueWithIdentifier:@"SegueName" sender:self]; 1) [self performSegueWithIdentifier:@"SegueName" sender:self];

do this in below method- 用以下方法做到这一点-

(void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath

2) set delegate of first tabel view. 2)设置第一个表格视图的委托

Hope it helps. 希望能帮助到你。

1 . 1。 Add segue from master table view to detail table view , just ctrl drag and select style as per your need 将segue从主表视图添加到明细表视图,只需按Ctrl拖动并根据需要选择样式

在此处输入图片说明

2 . 2。 set segue identifier 设置segue标识符

在此处输入图片说明

3 in did select use performSegueWithIdentifier to navigate 3中没有选择使用performSegueWithIdentifier进行导航

- (void)tableView:(UITableView *)tbView didSelectRowAtIndexPath:(NSIndexPath *)indexPath
 {
 [self performSegueWithIdentifier:@"Navigate" sender:self];
 }

转到情节提要,将单元格与目标视图链接,仅链接Ctrl拖动,然后在弹出菜单中选择“推”,然后选择链接并设置您的标识符(使用教程记忆的标识符),该方法将在处调用。内部补全事件,将调用您的方法

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM