OGeek|极客世界-中国程序员成长平台

标题: ios - 不调用 prepareForSegue [打印本页]

作者: 菜鸟教程小白    时间: 2022-12-12 17:36
标题: ios - 不调用 prepareForSegue

  1. 我使用 Storyboard 创建了一个 scrollView
  2. 我在 scrollViewController 中通过编程方式创建了 10 个 myController(它们是 UITableViewControllers),所以我可以使用 panGesture 在表格之间切换。并且运行良好。
  3. 我使用storyboard创建了一个tableViewController,设置myController为对应的 View Controller 。
  4. 在导航 Controller 中嵌入了 tableViewController
  5. 控制从表格单元格拖动到新的 View Controller 以创建推送转场。
  6. 设置转场。

在运行应用程序时,永远不会调用 prepareForSegue:

编辑:注意到这个问题后,我做了以下事情,但没有运气。

我还在 Storyboard 中正确设置了 segue 标识符。并添加以下代码:

- (void)tableViewUITableView *)tableView didSelectRowAtIndexPathNSIndexPath *)indexPath
{
    [self performSegueWithIdentifier"segueIdentifier" sender:self];
}

但是当我点击屏幕上的任何表格单元格时,程序将崩溃并出现以下错误:

* 由于未捕获的异常“NSInvalidArgumentException”而终止应用程序,原因:“Receiver () 没有标识符为“segueIdentifier”的segue” * 首先抛出调用栈:

这是为什么呢?



Best Answer-推荐答案


我认为您的问题在这里“5. 控制从表格单元格拖动到新 View Controller 以创建推送segue。

尝试从您的 View Controller (而不是表格单元格)拖动到新的 View Controller 并创建 push segue,然后尝试使用

- (void)tableViewUITableView *)tableView didSelectRowAtIndexPathNSIndexPath *)indexPath
{
    [self performSegueWithIdentifier"segueIdentifier" sender:self];
}

关于ios - 不调用 prepareForSegue,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/20828825/






欢迎光临 OGeek|极客世界-中国程序员成长平台 (http://sqlite.in/) Powered by Discuz! X3.4