开发者

UIScrollView not key value coding compliant for key view [duplicate]

开发者 https://www.devze.com 2023-01-07 02:33 出处:网络
This question already has answers here: Xcode - How to fix 'NSUnknownKeyException', reason: … this class is not key value coding-compliant for the key X" error?
This question already has answers here: Xcode - How to fix 'NSUnknownKeyException', reason: … this class is not key value coding-compliant for the key X" error? (78 answers) Closed 7 years ago.

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


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.

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号