0

在尝试tab-bar app使用许多不同的功能(例如UITableViewmapview注释)运行我时,我最近webview在我的firstviewcontroller. 据我所知,那里的编码没有任何问题,尽管自从我尝试在我的第一个选项卡上添加 webview 以来,我一直breakpoint/error在尝试运行应用程序:Thread 1: signal SIGBRT.

我已经阅读了一些,有人说如果我将 mi xib 文件/storyboard 的部署更改为 iOS 5.0 而不是 6.0(我目前正在使用)并且没有"Use Autolayout"检查它应该摆脱它。虽然它没有。对此有何想法或解决方案?

这是我的 firstviewcontroller.h 的编码

#import <UIKit/UIKit.h>


@interface FirstViewController : UIViewController
@property (weak, nonatomic) IBOutlet UIWebView *webView;

@end

第一视图控制器.m

#import "FirstViewController.h"

@interface FirstViewController ()

@end

@implementation FirstViewController
@synthesize webView;

- (void)viewDidLoad
{

    NSString *website = @"http://www.google.com";
    NSURL *url = [NSURL URLWithString:website];
    NSURLRequest *requestUrl = [NSURLRequest requestWithURL:url];
    [webView loadRequest:requestUrl];
    [super viewDidLoad];

}

- (void)didReceiveMemoryWarning
{
[super didReceiveMemoryWarning];

}

@end

主.m:

#import <UIKit/UIKit.h>

#import "AppDelegate.h"

int main(int argc, char *argv[])
{
    @autoreleasepool {
        return UIApplicationMain(argc, argv, nil, NSStringFromClass([AppDelegate class]));      // <--- HERE's where it says SIGBRT
    }
}

所有输出:

2013-01-04 11:27:06.697 My Corp[784:13d03] Unknown class ViewController in Interface Builder file.
2013-01-04 11:27:06.716 My Corp[784:13d03] *** Terminating app due to uncaught exception 'NSUnknownKeyException', reason: '[<FirstViewController 0x808fbf0> setValue:forUndefinedKey:]: this class is not key value coding-compliant for the key myWebView.'
*** First throw call stack:
(0x1800012 0x11c5e7e 0x1888fb1 0xc72711 0xbf3ec8 0xbf39b7 0xc1e428 0x32a0cc 0x11d9663 0x17fb45a 0x328bcf 0x1ede37 0x1ee418 0x1ee648 0x1ee882 0x20fed9 0x20fd14 0x20e1ea 0x20e06c 0x20c1cc 0x20c9b6 0x1f0753 0x1f0a7b 0x1f1964 0x154877 0x15b5a3 0x153eed 0x13db56 0x13ddbf 0x13df55 0x146f67 0x10afcc 0x10bfab 0x11d315 0x11e24b 0x10fcf8 0x1cc9df9 0x1cc9ad0 0x1775bf5 0x1775962 0x17a6bb6 0x17a5f44 0x17a5e1b 0x10b7da 0x10d65c 0x289d 0x27c5)
libc++abi.dylib: terminate called throwing an exception
(lldb) 
4

2 回答 2

1

在 .h 文件中设置 UIWebViewDelegate 并在 xib 中附加 webview 的委托

于 2013-01-04T10:25:07.853 回答
1

您所犯的错误已在崩溃报告中明确说明

[<FirstViewController 0x808fbf0> setValue:forUndefinedKey:]: this class is not key value coding-compliant for the key myWebView.'

要解决这个问题,请在InterfaceBuilder 左侧窗格中XIB右键单击该类。File owner您将找到一个名称myWebView带有黄色警告图标的对象,单击该插座连接上的删除并编译您的代码。您已经连接了插座,后来您删除了代码中的 IBOutlet,却忘记了删除 XIB 中的连接。

于 2013-01-04T10:37:27.827 回答