我正在尝试创建一个应用程序,它从一个主页开始,上面有三个按钮。按下的每个按钮都会切换到另一个视图。每个视图只是一个空视图,上面有一个UIWebView。在没有任何内容的情况下,转换到每个页面都很好。但是,当我添加UIWebview和所有正确的代码时,向页面的转换会导致应用程序崩溃,并带有以下错误消息:
* Terminating app due to uncaught exception 'NSUnknownKeyException',reason:‘setValue:forUndefinedKey::this class is not key value compliant for the key viewWeb.’* First throw call stack:(0x1c94012 0x10d1e7e 0x1d1cfb1 0xb7de41 0xaff5f8 0xaff0e7 0xb29b58 0x233019 0x10e5663 0x1c8f45a 0x231b1c 0xf67e7 0xf6dc8 0xf6ff8 0xf7232 0x259b 0x10e5705 0x192c0 0x19258 0xda021 0xda57f 0xd96e8 0x48cef 0x48f02 0x26d4a 0x18698 0x1befdf9 0x1befad0 0x1c09bf5 0x1c09962 0x1c3abb6 0x1c39f44 0x1c39e1b 0x1bee7e3 0x1bee668 0x15ffc 0x1e92 0x1dc5) libc++abi.dylib: terminate called throwing an exception
我肯定所有的UIWebView代码都是正确的,因为我在一个新的应用程序中测试了完全相同的代码,该应用程序只在一个视图上运行,并且没有转换。但是下面是我在转换过程中使用的代码:
- (IBAction)floorCatalog:(id)sender {
UIViewController* floorLampsViewController = [[UIViewController alloc] initWithNibName:@"floorLampsViewController" bundle:[NSBundle mainBundle]];
[self.view addSubview:floorLampsViewController.view];
}
- (void)dealloc {
[_floorLampsButton release];
[_tableLampsButton release];
[_wallLampsButton release];
[super dealloc];
}
- (void)viewDidUnload {
[self setFloorLampsButton:nil];
[self setTableLampsButton:nil];
[self setWallLampsButton:nil];
[super viewDidUnload];
}下面是我在网络视图中使用的代码:
@property (retain, nonatomic) IBOutlet UIWebView *viewWeb;
[self.viewWeb loadRequest:[NSURLRequest requestWithURL:[NSURL URLWithString:@"http://www.bing.com"]]];有什么原因吗?谢谢!
发布于 2013-07-18 21:41:00
viewWeb是否连接到接口生成器中的UIWebView?看起来viewWeb没有初始化什么的,而且看到您使用的是IBOutlet,我就觉得它在您的nib中。
https://stackoverflow.com/questions/17734209
复制相似问题