【问题标题】:TabBarController in SubView子视图中的 TabBarController
【发布时间】:2011-08-25 23:36:43
【问题描述】:

在我的 MainWindow.xib 中,我有以下结构:

-Files Owner
-First Responder
-MyApp App Delegate
-Window
-Tab Bar Controller
--Tab Bar
--Selected Recipes Nav Controller (recipes) - The class is set to a subclass of UINavigationController
--Other tabs…

我有用于编辑的详细信息视图,其中包含每个可编辑部分的选项卡,因此结构如下所示:

-Files Owner
-First Responder
-Tab Bar Controller
--Tab Bar
--Selected View Controller (recipes) - The class is set to a subclass of UINavigationController
---Scroll View
----UITextField (txtName)
----UITextField (txtDescription)
--Other tabs…

当用户单击主导航控制器上的添加工具栏按钮时,我想将此新视图推送到堆栈上,但出现异常:

* 由于未捕获的异常“NSUnknownKeyException”而终止应用程序, 原因:'[setValue:forUndefinedKey:]: 这个类不是关键值 txtName 键的编码兼容。'

我相信这可能是由于有两个标签控制器造成的。我尝试了以下方法来显示新的详细信息视图,但都抛出了相同的异常:

MyAppAppDelegate *delegate = [[UIApplication sharedApplication] delegate];
//[delegate.recipesNavController pushViewController:recipeDetailViewController animated:YES]; //- fails 
//[delegate.rootController presentModalViewController:recipeDetailViewController animated:YES]; //- fails
[self presentModalViewController:recipeDetailViewController animated:YES]; //- also fails

编辑:我现在不太确定,因为用 UISegmentedControl 替换它会导致类似的错误:

这个类不是键值 密钥的编码兼容 generalScroller。'

【问题讨论】:

    标签: iphone cocoa-touch ios interface-builder uitabbarcontroller


    【解决方案1】:

    你应该看看this,它似乎对here也有帮助。

    【讨论】:

    • 谢谢,但课程似乎按照描述设置。
    【解决方案2】:

    iOS 错误消息通常很中肯:它说哪个类不符合 KV?在某个地方,您正在使用 txName 和/或 generalScroller 设置 KVO,但有些东西要么没有监听这些,要么正在监听拼写错误的键名。

    【讨论】:

      【解决方案3】:

      问题是我错误地声明了视图控制器。我正在使用:

      RecipeDetailViewController *dvController = [[RecipeDetailViewController alloc] initWithNibName:@"RecipeDetailEditView" bundle:nil];
      

      当我需要时:

      RecipeDetailEditViewController *dvController = [[RecipeDetailEditViewController alloc] initWithNibName:@"RecipeDetailEditView" bundle:nil];
      

      【讨论】:

        猜你喜欢
        • 2011-02-19
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 2014-03-09
        • 1970-01-01
        • 2011-01-09
        相关资源
        最近更新 更多