我刚开始开发Mac应用程序,我想了一个网页视图URL时,应用程序start.Here是我的代码:如何在WebView(OSX项目)中启动时加载URL?
AppDelegate.h
#import <Cocoa/Cocoa.h>
#import <WebKit/WebKit.h>
@interface AppDelegate : NSObject <NSApplicationDelegate> {
WebView *myWebView;
//other instance variables
}
@property
(retain, nonatomic) IBOutlet WebView *myWebView;
//other properties and methods
@end
AppDelegate.m:
#import "AppDelegate.h"
#import <WebKit/WebKit.h>
@implementation AppDelegate
- (void)applicationDidFinishLaunching:(NSNotification *)aNotification
{
NSString *urlText = @"http://google.com";
[[self.myWebView mainFrame] loadRequest:[NSURLRequest requestWithURL:[NSURL URLWithString:urlText]]];
return;
// Insert code here to initialize your application
}
@end
如何在启动时在WebView(OSX项目)中加载URL?
我认为代码可以工作,但是当我尝试在Interface Builder中使用WebView连接代码时,我无法在插座列表中找到“网络视图”。 谢谢 我在更新我的代码后的最后一篇文章,但仍然无法正常工作。 再次感谢您的回复。
do @synthesize myWebView; ?? – iPatel 2013-04-10 09:32:42
@iPatel与最新的LLVM不再需要'@ synthesize'。 – rckoenes 2013-04-10 09:33:29
感谢您的回复!现在我可以从应用程序委托菜单中定义出口“Web视图”。但仍然无效:Web视图不加载URL。 – Skynext 2013-04-10 09:44:58