Skip to main content
 首页 » 编程设计

macos之webView不适用于osx

2025年12月25日36JeffreyZhao

我试图制作一个显示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 [])
{
返回NSApplicationMain(argc,(const char *)argv); //绿色标记:线程1:信号SIGABRT
}

请您参考如下方法:

你有没有尝试过:

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