UIScrollView 不符合键视图的键值编码
因此,按照这个问题 这里,我创建了两组新文件:
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 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
你的 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.