子视图中的 TabBarController
在我的 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 替换它会导致类似的错误:
该类不是键值 密钥的编码兼容 通用Scroller。'
In my MainWindow.xib, I have a the following structure:
-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…
I have details view for editing which contains tabs for each of the sections which can be edited, so the structure looks like this:
-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…
When the user clicks the add toolbar button on the main navigation controller, I want to push this new view onto the stack, but I get an exception:
* Terminating app due to uncaught exception 'NSUnknownKeyException',
reason: '[ setValue:forUndefinedKey:]:
this class is not key value
coding-compliant for the key txtName.'
I believe this could be caused by having two tab controllers. I've tried the following to show the new details view, but all throw the same exception:
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
EDIT: I'm not so sure now, as replacing it with a UISegmentedControl results in a similar error:
this class is not key value
coding-compliant for the key
generalScroller.'
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
您应该看看这个,它似乎也对这里有所帮助。
You should take a look at this, it seems to have helped here too.
iOS 错误消息通常很中肯:它说哪个类不符合 KV?在某个地方,您使用 txName 和/或 genericScroller 设置 KVO,但某些东西要么没有监听这些内容,要么正在监听拼写错误的键名称。
The iOS error messages are usually pretty to-the-point: what class is it saying is not KV compliant? Somewhere you're setting up a KVO with txName and/or generalScroller and something is either not listening for those or is listening for a mis-spelled key name.
问题是我错误地声明了视图控制器。我正在使用:
当我需要时:
The problem was I was declaring the view controller incorrectly. I was using:
When I needed: