[英]webView does not work for osx
我尝试制作一个显示google页面的webview,但是如果我运行我的程序,它将崩溃。 我在.h中的代码:
#import <Cocoa/Cocoa.h>
#import <WebKit/WebKit.h>
@interface AppDelegate : NSObject <NSApplicationDelegate>
@property (assign) IBOutlet NSWindow *window;
@property (weak) IBOutlet WebView *myWebView; //here I want to show google.com
@end
我在.m中的代码:
#import "AppDelegate.h"
@implementation AppDelegate
@synthesize myWebView;
- (void)applicationDidFinishLaunching:(NSNotification *)aNotification
{
[self loadWeb];
}
-(void)loadWeb {
[[webv mainFrame] loadRequest:[NSURLRequest requestWithURL:[NSURL URLWithString: @"http://www.google.de"]]]; // here I want to load the page
}
@end
这个问题总是说:int main(int argc,char argv []){return NSApplicationMain(argc,(const char * )argv); //绿色标记:线程1:signal SIGABRT}
你有没有尝试过:
#import <WebKit/WebView.h>
#import <WebKit/WebKit.h>
webview实例是IBOutlet,因此您应该从awakeFromNib调用它,类似这样,
-(void)awakeFromNib {[self loadWeb]; }
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.