Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/cocoa/3.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Cocoa 网络视图问题_Cocoa_Macos - Fatal编程技术网

Cocoa 网络视图问题

Cocoa 网络视图问题,cocoa,macos,Cocoa,Macos,我的程序有两个类,第一个类是常规应用程序委托NSObject。第二个是一个NSWindowController子类,上面有NSWindow和WebView,它显示应用程序包中的html页面 以下是我如何从AppDelegate调用窗口: -(IBAction)showWebViewForm:(id)sender { webViewForm = [[WebViewForm alloc] initWithWindowNibName:@"WebViewForm"]; [webViewF

我的程序有两个类,第一个类是常规应用程序委托
NSObject
。第二个是一个
NSWindowController
子类,上面有NSWindow和WebView,它显示应用程序包中的html页面

以下是我如何从AppDelegate调用窗口:

-(IBAction)showWebViewForm:(id)sender
{
    webViewForm = [[WebViewForm alloc] initWithWindowNibName:@"WebViewForm"];
    [webViewForm showWindow:self];
}
以下是我在
WebViewForm:NSWindowController
中呈现网页的方式:

-(void)awakeFromNib{
    [NSApp activateIgnoringOtherApps:YES];
    [webview setUIDelegate: self];
    [webview setResourceLoadDelegate: self];
    [webview setPolicyDelegate:self];
    [webview setFrameLoadDelegate:self];

    [[webview mainFrame] loadRequest:
     [NSURLRequest requestWithURL:
      [NSURL fileURLWithPath:
       [[NSBundle mainBundle] pathForResource:@"index" ofType:@"html" inDirectory:@"data"]]]];

}
这很好,但只是第一次。当我关闭
WebViewForm
窗口并重新打开它时,网页正在从WebView中消失。为什么会这样,如何解决


UPD即使在特殊的新方法中嵌入
awakeFromNib
代码,如
-(void)refreshWebview
,然后在
[webViewForm showWindow:self]之后立即调用
[webViewForm refreshWebview]
,仍然是第一次加载页面,这真的很奇怪(有什么想法吗?

我自己想出来的。问题是,webview在父窗口关闭时关闭了。因此,对于这种情况,有一种特殊的方法:

[网络视图设置应关闭窗口:否];