【发布时间】:2011-03-28 21:01:04
【问题描述】:
好的,到目前为止,我已经按照其他人的答案编写了整个代码,但是当我构建和运行我的项目时,我在代码中指定的网站或 html 文件不会显示在屏幕上;只显示一个白屏。
这是我迄今为止对头文件所做的:
//MY HEADER FILE(.h):
#import <Cocoa/Cocoa.h>
#import <WebKit/WebKit.h>
@interface Project_XAppDelegate: NSObject <NSApplicationDelegate> {
NSWindow *window;
IBOutlet WebView *webView;
}
@property (assign) IBOutlet NSWindow *window;
@property (nonatomic, retain) IBOutlet WebView *webView;
@end
实施:
//MY IMPLEMENTATION FILE(.m):
#import "Project_XAppDelegate.h"
#import "WebKit/Webkit.h"
@implementation Project_XAppDelegate
@synthesize window;
@synthesize webView;
- (void)applicationDidFinishLaunching:(NSNotification *)aNotification {
}
- (void)awakeFromNib {
NSString *resourcesPath = [[NSBundle mainBundle] resourcePath];
NSString *htmlPath = [resourcesPath stringByAppendingString:@"/Users/*****/Desktop/Project X/HTML/mehmar.html"];
[[webView mainFrame] loadRequest:[NSURLRequest requestWithURL:[NSURL fileURLWithPath:htmlPath]]];
}
@end
【问题讨论】: