UIScrollView 不符合键视图的键值编码

发布于 2024-09-10 05:11:11 字数 1375 浏览 2 评论 0原文

因此,按照这个问题 这里,我创建了两组新文件:

JCScrollViewController.m  
JCScrollViewController.xib

JCKeyboard.xib

JCScrollViewController.xib 中,我只有一个滚动视图,.m 文件的 scrollView 出口连接到它,视图插座连接到视图。 JCScrollViewController.m 符合 UIScrollViewDelegate

在我的应用程序委托中,我执行此操作:

JCScrollViewController *viewController = [[JCScrollViewController alloc] init];
[window addSubview:viewController.view];

JCScrollViewController.m 中,我在 -viewDidLoad 中执行此操作:

//load your JCKeyboard.xib into a UIView object
NSArray *nibParts = [[NSBundle mainBundle] loadNibNamed:@"JCKeyboard" 
                                                  owner:nil 
                                                options:nil];
//first object is the view
UIView *keyboard = [nibParts objectAtIndex:0];

//add keyboard to scrollView 
[scrollView addSubview:keyboard];

//set content size to same dimensions as TallView.xib
scrollView.contentSize = CGSizeMake(320, 600);

当我启动应用程序时,我收到此错误:

this class is not key value coding-compliant for the key view.

什么会导致此错误?

谢谢

So following this SO question Here, i created two new sets of files:

JCScrollViewController.m  
JCScrollViewController.xib

JCKeyboard.xib

In JCScrollViewController.xib i have just a scroll view, with the scrollView outlet of the .m file connected to it, the view outlet is connected to the View. The JCScrollViewController.m conforms to the UIScrollViewDelegate.

In my app delegate i do this:

JCScrollViewController *viewController = [[JCScrollViewController alloc] init];
[window addSubview:viewController.view];

In JCScrollViewController.m i do this in -viewDidLoad:

//load your JCKeyboard.xib into a UIView object
NSArray *nibParts = [[NSBundle mainBundle] loadNibNamed:@"JCKeyboard" 
                                                  owner:nil 
                                                options:nil];
//first object is the view
UIView *keyboard = [nibParts objectAtIndex:0];

//add keyboard to scrollView 
[scrollView addSubview:keyboard];

//set content size to same dimensions as TallView.xib
scrollView.contentSize = CGSizeMake(320, 600);

When i launch the app i get this error:

this class is not key value coding-compliant for the key view.

What would cause this?

Thanks

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

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

发布评论

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

评论(1

风和你 2024-09-17 05:11:11

你的 JCScrollViewController 是否正确扩展了 UIViewController?如果不确定,请显示您的头文件。

您可能有一个指向 IB 中名为“view”的链接,而链接到的类没有名为“view”的 IBOutlet - 因此会出现错误。 IB 应该将其显示为黄色链接。

Does your JCScrollViewController properly extend UIViewController? If unsure, show your header file.

You probably have a link to something called "view" in IB, whereas the class linked to doesn't have an IBOutlet called "view" - hence the error. IB should show this as a yellow-ish link.

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