2

I am new to iPhone App development.

I got this error when I run my project

Terminating app due to uncaught exception 'NSUnknownKeyException',
reason: '[<AboutViewController 0x91cc1d0> setValue:forUndefinedKey:]:

It happens when I try to navigate to another view controller called AboutViewController.

I defined the rightBarButton like this

UIBarButtonItem *anotherButton = [[UIBarButtonItem alloc] initWithTitle:@"About" style:UIBarButtonItemStylePlain target:self :@selector(showAbout)];
self.navigationItem.rightBarButtonItem = anotherButton;

The method showAbout is

- (void)showAbout{

    AboutViewController *abvController = [[AboutViewController alloc] initWithNibName:@"AboutViewController" bundle:nil];

    [self.navigationController pushViewController:abvController animated:YES];    
    [abvController release];
}

Also when I try to use presentModelViewController instead of navigationController, the compiler shows it is deprecated.

Tobi
  • 5,499
  • 3
  • 31
  • 47
nbs
  • 573
  • 1
  • 6
  • 15

3 Answers3

1

I found the problem, it was because of a button i used in the AboutViewController, i didnt declare the property for that button.

but can anyone tell me how to use ModelViewController to goto a new view in ios6, since when i use the method presentModelViewController, it shows a warning that it is deprecated

nbs
  • 573
  • 1
  • 6
  • 15
  • 1
    The documentation (http://developer.apple.com/library/ios/#documentation/uikit/reference/UIViewController_Class/DeprecationAppendix/AppendixADeprecatedAPI.html#//apple_ref/occ/instm/UIViewController/presentModalViewController:animated:) tells you to use presentViewController:animated:completion: – Michele Percich Nov 09 '12 at 09:39
0

I think the problem is your AboutViewController, not in current view controller.

I guess your AboutViewController nib class is UIViewController class not AboutViewController class, try to change it to the right class. Click your nib file, and then click your file's owner, and then in the right section click third tab. You should see class in the top, change it to AboutViewCtroller.

brianLikeApple
  • 4,262
  • 1
  • 27
  • 46
0

Usually these types of error occur due to the problems with the outlets connected in xib. Main scenarios:

  1. View outlet is not connected in xib
  2. Connected outlet's property is deleted from interface file

    presentModelViewController is deprecated in iOS 6. Instead you can use presentViewController:animated:completion: for presenting the modalViews.

presentViewController:animated:completion:

Presents a view controller.

- (void)presentViewController:(UIViewController *)viewControllerToPresent animated:(BOOL)flag completion:(void (^)(void))completion

Parameters

viewControllerToPresent

The view controller being presented.

flag

Pass YES to animate the presentation; otherwise, pass NO.

completion

A completion handler or NULL.

Discussion

On iPhone and iPod touch, the presented view is always full screen. On iPad, the presentation depends on the value in the modalPresentationStyle property.

This method sets the presentedViewController property to the specified view controller, resizes that view controller’s view and then adds the view to the view hierarchy. The view is animated onscreen according to the transition style specified in the modalTransitionStyle property of the presented view controller.

The completion handler is called after the viewDidAppear: method is called on the presented view controller.

Availability

Available in iOS 5.0 and later.

Declared In UIViewController.h

For more details check UIViewController Class

Midhun MP
  • 103,496
  • 31
  • 153
  • 200