2014-02-25 77 views
-1

我在运行我的xcode项目时收到错误。我的应用程序总是工作,所以我不明白为什么这不再工作。有人有想法吗?我发现这是由于我打电话的方法无效造成的。我似乎无法弄清楚这个错误所在的位置..有人吗?线程1:信号SIGBRT

的错误,我得到:

2014-02-25 11:52:06.784 Chemie Xpert - PSE[1381:70b] *** Terminating app due to uncaught exception 'NSUnknownKeyException', reason: '[<UIApplication 0x8d49be0> setValue:forUndefinedKey:]: this class is not key value coding-compliant for the key view.' 
*** First throw call stack: 
(
    0 CoreFoundation      0x023625e4 __exceptionPreprocess + 180 
    1 libobjc.A.dylib      0x014bc8b6 objc_exception_throw + 44 
    2 CoreFoundation      0x023f26a1 -[NSException raise] + 17 
    3 Foundation       0x00f709ee -[NSObject(NSKeyValueCoding) setValue:forUndefinedKey:] + 282 
    4 Foundation       0x00edccfb _NSSetUsingKeyValueSetter + 88 
    5 Foundation       0x00edc253 -[NSObject(NSKeyValueCoding) setValue:forKey:] + 267 
    6 Foundation       0x00f3e70a -[NSObject(NSKeyValueCoding) setValue:forKeyPath:] + 412 
    7 UIKit        0x002bfa15 -[UIRuntimeOutletConnection connect] + 106 
    8 libobjc.A.dylib      0x014ce7d2 -[NSObject performSelector:] + 62 
    9 CoreFoundation      0x0235db6a -[NSArray makeObjectsPerformSelector:] + 314 
    10 UIKit        0x002be56e -[UINib instantiateWithOwner:options:] + 1417 
    11 UIKit        0x002c02fb -[NSBundle(UINSBundleAdditions) loadNibNamed:owner:options:] + 165 
    12 UIKit        0x0001d3bb -[UIApplication _loadMainNibFileNamed:bundle:] + 58 
    13 UIKit        0x0001d6e9 -[UIApplication _loadMainInterfaceFile] + 245 
    14 UIKit        0x0001c28f -[UIApplication _runWithURL:payload:launchOrientation:statusBarStyle:statusBarHidden:] + 543 
    15 UIKit        0x0003087c -[UIApplication handleEvent:withNewEvent:] + 3447 
    16 UIKit        0x00030de9 -[UIApplication sendEvent:] + 85 
    17 UIKit        0x0001e025 _UIApplicationHandleEvent + 736 
    18 GraphicsServices     0x022c02f6 _PurpleEventCallback + 776 
    19 GraphicsServices     0x022bfe01 PurpleEventCallback + 46 
    20 CoreFoundation      0x022ddd65 __CFRUNLOOP_IS_CALLING_OUT_TO_A_SOURCE1_PERFORM_FUNCTION__ + 53 
    21 CoreFoundation      0x022dda9b __CFRunLoopDoSource1 + 523 
    22 CoreFoundation      0x0230877c __CFRunLoopRun + 2156 
    23 CoreFoundation      0x02307ac3 CFRunLoopRunSpecific + 467 
    24 CoreFoundation      0x023078db CFRunLoopRunInMode + 123 
    25 UIKit        0x0001badd -[UIApplication _run] + 840 
    26 UIKit        0x0001dd3b UIApplicationMain + 1225 
    27 Chemie Xpert - PSE     0x0000247d main + 141 
    28 libdyld.dylib      0x0598d70d start + 1 
) 
libc++abi.dylib: terminating with uncaught exception of type NSException 
(lldb) 

我的代码:

的main.m:

#import <UIKit/UIKit.h> 

#import "AppDelegate.h" 

int main(int argc, char *argv[]) 
{ 
    @autoreleasepool { 
     return UIApplicationMain(argc, argv, nil, NSStringFromClass([AppDelegate class])); 
    } 
} 

ViewController.m:

#import "ViewController.h" 
@interface ViewController() 
@end 
@implementation ViewController 
@synthesize webview; 

- (void)viewDidLoad 
{ 
    [super viewDidLoad]; 
    NSString *path = [[NSBundle mainBundle] pathForResource:@"index" ofType:@"html" inDirectory:@"localHTML"]; 
    NSURL *url = [NSURL fileURLWithPath:path]; 
    NSURLRequest *request = [NSURLRequest requestWithURL:url]; 
    [webview loadRequest:request]; 

    webview.scalesPageToFit = YES; 
    webview.scrollView.bounces = NO; 
    webview.scrollView.minimumZoomScale = 1; 
    webview.scrollView.bouncesZoom = FALSE; 

} 


- (void)didReceiveMemoryWarning 
{ 
    [super didReceiveMemoryWarning]; 
    // Dispose of any resources that can be recreated. 
} 

- (BOOL)prefersStatusBarHidden 
{ 
    return YES; 
} 
@end 
+0

另请参阅:http://stackoverflow.com/questions/3088059/this-class-is-not-key-value-coding-compliant-for-the-key – Amar

+0

另请参阅:http://stackoverflow.com/questions/5109309/this-class-not-key-value-coding-compliant-for-the-key-authview – Amar

+0

你能否显示你的viewCotnroller.h? –

回答

0

也许你删除的UIView客体来回在NIB中替换为UIWebView。 这很好,但是您应该将webView链接到xib文件中的viewController"view"属性。

0

Webview设置为IBOutlet吗?这可能是原因。

+0

的确不错,我ViewController.h: ' #import @interface ViewController:UIViewController {IBOutlet UIWebView * webview; } @property(nonatomic,retain)UIWebView * webview; @ end' – Robbie