My program have two classes, first of them is regular app delegate NSObject
. The second one is a NSWindowController
subclass with NSWindow and WebView on it, which shows html page from application bundle.
Here is how i call window from AppDelegate:
-(IBAction)showWebViewForm:(id)sender
{
webViewForm = [[WebViewForm alloc] initWithWindowNibName:@"WebViewForm"];
[webViewForm showWindow:self];
}
Here is how i render the webpage in 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"]]]];
}
It's work fine, but only for the first time. When i close WebViewForm
window and reopen it, webpage is disappearing from WebView. Why is so that, and how to fix it?
UPD Even if embed awakeFromNib
code in special new method like -(void)refreshWebview
and then call [webViewForm refreshWebview]
right after [webViewForm showWindow:self];
, still — page loads only for first time, and it's really weird ( Any ideas?