在我的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…当用户单击主导航控制器上的add工具栏按钮时,我想将这个新视图推到堆栈上,但我得到了一个例外:
*终止应用程序,原因:“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‘
的键值编码。
发布于 2011-05-16 17:35:26
问题是我不正确地声明了视图控制器。我用的是:
RecipeDetailViewController *dvController = [[RecipeDetailViewController alloc] initWithNibName:@"RecipeDetailEditView" bundle:nil];当我需要的时候
RecipeDetailEditViewController *dvController = [[RecipeDetailEditViewController alloc] initWithNibName:@"RecipeDetailEditView" bundle:nil];发布于 2011-05-15 19:07:53
iOS错误消息通常非常重要:它说的是哪些类不兼容KV?在某个地方,您正在用txName和/或generalScroller设置一个KVO,有些东西不是在监听这些KVO,就是在侦听拼写错误的密钥名。
https://stackoverflow.com/questions/6009999
复制相似问题