子视图中的 TabBarController

发布于 2024-11-07 12:44:54 字数 1396 浏览 1 评论 0原文

在我的 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 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(3

白首有我共你 2024-11-14 12:44:54

您应该看看这个,它似乎也对这里有所帮助。

You should take a look at this, it seems to have helped here too.

ぺ禁宫浮华殁 2024-11-14 12:44:54

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.

独闯女儿国 2024-11-14 12:44:54

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

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

当我需要时:

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

The problem was I was declaring the view controller incorrectly. I was using:

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

When I needed:

RecipeDetailEditViewController *dvController = [[RecipeDetailEditViewController alloc] initWithNibName:@"RecipeDetailEditView" bundle:nil];
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文