【发布时间】:2012-04-08 02:03:58
【问题描述】:
只是想制作一个简单的 WebView Mac 应用。
我已经导入了 WebKit.h,声明了一个 WebView @property,并在 .m 中对其进行了@synthesized,但是当我进入 IB 和连接选项卡时,我的出口,比如 MyWebView,并没有列出。
.h
#import <Cocoa/Cocoa.h>
#import <WebKit/WebKit.h>
@interface MyAppDelegate : NSObject <NSApplicationDelegate> {
NSWindow *window;
IBOutlet WebView *MyView;
}
@property (assign) IBOutlet NSWindow *window;
@property (nonatomic, retain) IBOutlet WebView *MyView;
@end
.m
@synthesize MyView;
最新版本的 Xcode。想法?
【问题讨论】:
-
您是否正确检查了插座?引导我们完成它(或者截图可能会很好)
-
检查插座是什么意思?我正在 IB 中查看我的 XIB 文件,位于 Connections Inspector 选项卡 > Outlets...
-
好的,我想通了...我正在查看 WebView 的连接检查器,而不是 AppDelegate。呃。但是,当启动时,它仍然是空白的(即使现在 WebView 已连接到 IBOutlet)......在 applicationDidFinishLaunching: 中使用相同的代码:正如我之前发布的......该代码看起来不错吗?为什么我在运行应用程序时仍然出现空白屏幕?
-
其实我之前好像没发过...
- (void)awakeFromNib { NSString *resourcesPath = [[NSBundle mainBundle] resourcePath]; NSString *htmlPath = [resourcesPath stringByAppendingString:@"/htdocs/index.html"]; [[webView mainFrame] loadRequest:[NSURLRequest requestWithURL:[NSURL fileURLWithPath:htmlPath]]]; }
标签: objective-c xcode cocoa webkit webview