2012-09-16 52 views
0

我嘗試製作一個webview,顯示谷歌的頁面,但是如果我運行我的程序它只是崩潰。 我在.H代碼:webView不適用於osx

#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主(INT ARGC,CHAR 的argv []){ 回報 NSApplicationMain (argc,(const char *)argv); //綠標:線程1:信號SIGABRT }

回答

0

你試過:

#import <WebKit/WebView.h> 
#import <WebKit/WebKit.h> 
0

web視圖實例是一個IBOutlet,所以你應該從awakeFromNib,像這樣稱呼它,

- (void)awakeFromNib {self_loadWeb]; }

相關問題