UIWebView抛出NSUnknownKeyException iPad [英] UIWebView throwing NSUnknownKeyException iPad
问题描述
我有一个标签栏应用程序.一切正常,除了可以切换到第二个选项卡ProductViewClass
之外,其他所有选项卡都可以正常切换,该视图不会更新,并且会吐出下面的控制台输出.除了UIWebView和UILabel,在此视图中我什么都没有.当我删除UIWebView时,它可以成功运行,而当我添加另一个时,它仍然可以工作.仅当我将IBOutlet从文件所有者连接到UIWebView时,它才会停止工作.除了合成和发布productWebView
之外,ProductWebView.m
中唯一的非模板代码是:
I have a tab bar application. Everything works normally, and I can switch between tabs fine and everything, except when I switch to my second tab ProductViewClass
the view doesn't update and it spits out the console output below. I have nothing in this view except for a UIWebView and a UILabel. When I delete the UIWebView it runs successfully, and when I add another it still works. It only stops working when I connect the IBOutlet from my File's Owner to the UIWebView. Besides synthesizing and releasing productWebView
the only non-template code in ProductWebView.m
is this:
NSString *urlString = @"http://www.google.com/";
NSURL *theURL = [NSURL URLWithString:urlString];
NSURLRequest *urlRequest = [NSURLRequest requestWithURL:theURL];
[productWebView loadRequest:urlRequest];
NSLog(@"Google loaded");
ProductWebView.h的整体如下:
The entirety of ProductWebView.h is as follows:
#import <UIKit/UIKit.h>
@interface ProductViewClass : UIViewController {
IBOutlet UIWebView *productWebView;
}
@property(nonatomic, retain) UIWebView *productWebView;
@end
这是控制台输出:
This GDB was configured as "x86_64-apple-darwin".Attaching to process 52523.
2011-01-30 19:18:28.907 FairCom[52523:40b] *** Terminating app due to uncaught exception 'NSUnknownKeyException', reason: '[<UIViewController 0x4d06eb0> setValue:forUndefinedKey:]: this class is not key value coding-compliant for the key productWebView.'
*** Call stack at first throw:
(
0 CoreFoundation 0x00da8be9 __exceptionPreprocess + 185
1 libobjc.A.dylib 0x00efd5c2 objc_exception_throw + 47
2 CoreFoundation 0x00da8b21 -[NSException raise] + 17
3 Foundation 0x000296cf _NSSetUsingKeyValueSetter + 135
4 Foundation 0x0002963d -[NSObject(NSKeyValueCoding) setValue:forKey:] + 285
5 UIKit 0x004a88d6 -[UIRuntimeOutletConnection connect] + 112
6 CoreFoundation 0x00d1f2cf -[NSArray makeObjectsPerformSelector:] + 239
7 UIKit 0x004a72ed -[UINib instantiateWithOwner:options:] + 1041
8 UIKit 0x004a9081 -[NSBundle(UINSBundleAdditions) loadNibNamed:owner:options:] + 168
9 UIKit 0x00361a94 -[UIViewController _loadViewFromNibNamed:bundle:] + 70
10 UIKit 0x0035f709 -[UIViewController loadView] + 120
11 UIKit 0x0035f5e3 -[UIViewController view] + 56
12 UIKit 0x00372230 -[UITabBarController transitionFromViewController:toViewController:transition:shouldSetSelected:] + 120
13 UIKit 0x00370d86 -[UITabBarController transitionFromViewController:toViewController:] + 64
14 UIKit 0x00372b7e -[UITabBarController _setSelectedViewController:] + 263
15 UIKit 0x003729ed -[UITabBarController _tabBarItemClicked:] + 352
16 UIKit 0x002b1a6e -[UIApplication sendAction:to:from:forEvent:] + 119
17 UIKit 0x004af1f2 -[UITabBar _sendAction:withEvent:] + 422
18 UIKit 0x002b1a6e -[UIApplication sendAction:to:from:forEvent:] + 119
19 UIKit 0x003401b5 -[UIControl sendAction:to:forEvent:] + 67
20 UIKit 0x00342647 -[UIControl(Internal) _sendActionsForEvents:withEvent:] + 527
21 UIKit 0x0034016c -[UIControl sendActionsForControlEvents:] + 49
22 UIKit 0x002b1a6e -[UIApplication sendAction:to:from:forEvent:] + 119
23 UIKit 0x003401b5 -[UIControl sendAction:to:forEvent:] + 67
24 UIKit 0x00342647 -[UIControl(Internal) _sendActionsForEvents:withEvent:] + 527
25 UIKit 0x003411f4 -[UIControl touchesEnded:withEvent:] + 458
26 UIKit 0x002d60d1 -[UIWindow _sendTouchesForEvent:] + 567
27 UIKit 0x002b737a -[UIApplication sendEvent:] + 447
28 UIKit 0x002bc732 _UIApplicationHandleEvent + 7576
29 GraphicsServices 0x016dea36 PurpleEventCallback + 1550
30 CoreFoundation 0x00d8a064 __CFRUNLOOP_IS_CALLING_OUT_TO_A_SOURCE1_PERFORM_FUNCTION__ + 52
31 CoreFoundation 0x00cea6f7 __CFRunLoopDoSource1 + 215
32 CoreFoundation 0x00ce7983 __CFRunLoopRun + 979
33 CoreFoundation 0x00ce7240 CFRunLoopRunSpecific + 208
34 CoreFoundation 0x00ce7161 CFRunLoopRunInMode + 97
35 GraphicsServices 0x016dd268 GSEventRunModal + 217
36 GraphicsServices 0x016dd32d GSEventRun + 115
37 UIKit 0x002c042e UIApplicationMain + 1160
38 FairCom 0x00001be0 main + 102
39 FairCom 0x00001b71 start + 53
40 ??? 0x00000001 0x0 + 1
)
terminate called after throwing an instance of 'NSException'
sharedlibrary apply-load-rules all
(gdb)
感谢您的帮助!
推荐答案
您正在加载笔尖.在该笔尖中,您有一个名为productWebView
的插座,该插座可能已挂接到网络视图.您看到的异常是告诉您出口productWebView
实际上并不存在.这是奇怪的地方.该错误表明对象<UIViewController 0x4d06eb0>
是缺少此出口的对象.奇怪的地方是UIViewController
而不是实际的视图控制器子类的名称.听起来好像您有一个笔尖,其中文件所有者"被设置为您的视图控制器子类之一,但是在运行时,您实际上实际上只是直接使用UIViewController
的实例.您应该验证所有在选项卡栏控制器中代表选项卡的视图控制器都是UIViewController
的实际正确子类,而不仅仅是UIViewController
本身的实例.
You're loading a nib. In that nib, you have an outlet named productWebView
that's hooked up, presumably to a web view. The exception you're seeing is telling you that the outlet productWebView
doesn't actually exist. Here's where it gets weird. The error says the object <UIViewController 0x4d06eb0>
is the one that has this missing outlet. The weird bit is where it says UIViewController
instead of the name of an actual view controller subclass. It sounds like you have a nib where the File's Owner is set up as one of your view controller subclasses, but at runtime you're actually just using an instance of UIViewController
directly. You should verify that all the view controllers representing tabs in your tab bar controller are actual correct subclasses of UIViewController
instead of just an instance of UIViewController
itself.
这篇关于UIWebView抛出NSUnknownKeyException iPad的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!