开发者

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

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

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜