0
大家好,我需要一些幫助。我正在嘗試爲Xcode 4.0中的mac創建一個應用程序,並且我希望它在啓動時顯示一個網頁,我已經添加了webkit框架並獲得了一些代碼,但它不工作。代碼如下如何在打開應用程序時啓動網頁
的應用delegate.m文件
#import "AppDelegate.h"
#import <WebKit/WebKit.h>
@implementation AppDelegate
@synthesize window = _window;
@synthesize WebView;
- (void)applicationDidFinishLaunching:(NSNotification *)aNotification
{
NSString *urlAddress = @"http://www.google.com/";
NSURL *url = [NSURL URLWithString:urlAddress];
NSURLRequest *requestObj = [NSURLRequest requestWithURL:url];
[[WebView mainFrame] LoadRequest:requestObj];
}
@end
和應用程序delegate.h文件
#import <Cocoa/Cocoa.h>
#import <WebKit/WebKit.h>
@interface AppDelegate : NSObject <NSApplicationDelegate>
@property (assign) IBOutlet NSWindow *window;
@property (assign) IBOutlet WebView *WebView;
@interface myAppDelegate : NSObject <NSApplicationDelegate> {
WebView *myWebView;
}
@property (retain, nonatomic) IBOutlet WebView *myWebView;
@end
如果有人可以幫助請儘快迴應謝謝你們!
謝謝解決它的另一個原因是我忘了將web視圖連接到mywebview屬性 – Blizardy