2011-12-22 21 views
0

こんにちは皆、何か助けが必要です。私はXcode 4.0でMac用のアプリケーションを作成しようとしています。起動時にWebページを表示したいのですが、既にWebkitフレームワークを追加していますが、コードはありませんが動作しません。誰もができるだけ早くおかげでみんなをご返信ください助けることができる場合はコードがアプリケーションの開封時にWebページを起動するには

の下にアプリの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 

です!

答えて

0

hmm、私はコードがコンパイルされていないと仮定していますか? (すべきではありません!:))。

#import <Cocoa/Cocoa.h> 

#import <WebKit/WebKit.h> 

@interface AppDelegate : NSObject <NSApplicationDelegate> { 
    WebView *_myWebView; // not needed if you're using the latest xcode 
} 

@property (assign) IBOutlet NSWindow *window; 
@property (retain, nonatomic) IBOutlet WebView *myWebView; 

@end 

との.m:

#import "AppDelegate.h" 

#import <WebKit/WebKit.h> 

@implementation AppDelegate 

@synthesize window = _window; 
@synthesize myWebView = _myWebView; 

- (void)applicationDidFinishLaunching:(NSNotification *)aNotification 
{ 
    NSString *urlAddress = @"http://www.google.com/"; 
    NSURL *url = [NSURL URLWithString:urlAddress]; 
    NSURLRequest *requestObj = [NSURLRequest requestWithURL:url]; 
    [[self.myWebView mainFrame] loadRequest:requestObj]; // note the lower case 'l' in 'loadRequest' 
} 

@end 

これはあなたがmyWebViewプロパティで.xibでのWebViewを接続したと仮定した.hは次のようになります。それを固定

+0

感謝の男は別の理由も、私はmywebviewプロパティでWeb表示を接続するのを忘れました。 – Blizardy

関連する問題