2012-11-09 49 views
2

我是iPhone App开发的新手。因未捕获异常'NSUnknownKeyException'而终止应用,原因:'[<AboutViewController 0x91cc1d0> setValue:forUndefinedKey:]:

,当我跑我的项目

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

,当我尝试导航到另一个名为AboutViewController视图控制器这种事我得到这个错误。

我所定义的rightBarButton这样

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

方法showAbout

- (void)showAbout{ 

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

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

此外,当我尝试使用presentModelViewController代替navigationController,编译器显示它已被弃用。

回答

0

我认为问题是你的AboutViewController,而不是当前的视图控制器。

我想你的AboutViewController的nib类是UIViewController类不是AboutViewController类,试着将它改为正确的类。点击你的笔尖文件,然后点击你的文件的所有者,然后在右侧部分点击第三个标签。您应该在顶部看到类,将其更改为AboutViewCtroller。

1

我发现这个问题,这是因为我在AboutViewController中使用了一个按钮,我没有声明该按钮的属性。

但谁能告诉我怎么用ModelViewController来转到一个新的观点在iOS6的,因为当我使用的方法presentModelViewController,它显示了一个警告,它已被弃用通常这些类型的错误发生

+1

的文档(http://developer.apple.com/library/ios/ #文档/ UIKit的/参照/ UIViewController_Class/DeprecationAppendix/AppendixADeprecatedAPI.html#// apple_ref/OCC/instm/UIViewController中/ presentModalViewController:ANI配合:)告诉你使用presentViewController:动画:完成: –

+0

@michele:谢谢 – nbs

0

因与xib连接的插座有问题。 主要场景:

  1. 查看插座没有连接在厦门国际银行
  2. 连接的插座的财产是从接口文件中删除

    presentModelViewController中的iOS 6弃用相反,你可以使用presentViewController:animated:completion:用于呈现modalViews。

presentViewController:动画:完成:

呈现一个视图控制器。

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

参数

viewControllerToPresent

The view controller being presented. 

标志

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

完成

A completion handler or NULL. 

讨论

在iPhone和iPod touch,所提出的观点总是充满屏幕。在 iPad上,演示文稿取决于 modalPresentationStyle属性中的值。

此方法将presentViewController属性设置为指定的 视图控制器,调整该视图控制器视图的大小,然后将视图添加到视图层次结构中。该视图在屏幕上根据 在屏幕上以 的modalTransitionStyle属性中指定的过渡样式显示在视图控制器中。

完成处理程序的viewDidAppear之后调用:方法是 称为所呈现的视图控制器上。

状况

Available in iOS 5.0 and later. 

宣布UIViewController.h

详情检查UIViewController Class

相关问题