亚洲国产日韩欧美一区二区三区,精品亚洲国产成人av在线,国产99视频精品免视看7,99国产精品久久久久久久成人热,欧美日韩亚洲国产综合乱

Objective-c - WebView cannot respond to modal window when loading html
天蓬老師
天蓬老師 2017-05-02 09:23:47
0
2
817

RT, in WebView under OSX (not iOS), when loading an html web page, the js window.showModalDialog is invalid and the window cannot pop up. When loading the same web page in Safari, there is a response. Has anyone done something similar? Problem?
The code is as follows:

- (WebView *)webView:(WebView *)sender createWebViewWithRequest:(NSURLRequest *)request{
    
    NSWindow *window = [[NSWindow alloc] initWithContentRect:NSMakeRect(0, 0, 400, 300) styleMask:NSTitledWindowMask | NSClosableWindowMask | NSMiniaturizableWindowMask | NSResizableWindowMask backing:NSBackingStoreBuffered defer:YES];
    [window setCollectionBehavior:NSWindowCollectionBehaviorFullScreenPrimary];
    WebView *webView = [[WebView alloc] init];
    [webView setFrameLoadDelegate:self];
    window.contentView = webView;
    [webView.mainFrame loadRequest:request];
    [window makeKeyAndOrderFront:self];
    return webView;
    
}

- (WebView *)webView:(WebView *)sender createWebViewModalDialogWithRequest:(NSURLRequest *)request{
 
   return [self webView:sender createWebViewWithRequest:request];

}

- (void)webViewRunModal:(WebView *)sender{

   [sender.window makeKeyAndOrderFront:self];
    
}

- (void)webViewShow:(WebView *)sender{
    
    [sender.window makeKeyAndOrderFront:self];
    
}

- (void)webViewClose:(WebView *)sender{

    [sender.window close];
    
}
天蓬老師
天蓬老師

歡迎選擇我的課程,讓我們一起見(jiàn)證您的進(jìn)步~~

reply all(2)
給我你的懷抱

It is best not to use showModalDialog. It is better to change it to p. I have never used the osx webview, but when I was doing Android development before, the webview did not support the pop-up of the modal window. It is better to change it to p. I don’t know about osx. Is this the reason why webview does not pop up

黃舟

After debugging for a long time, I finally solved it. Please provide the code to give others an idea.

     #pragma -mark -WebView Delegate
    
        - (WebView *)webView:(WebView *)sender createWebViewWithRequest:(NSURLRequest *)request{
     NSUInteger windowStyleMask = NSClosableWindowMask|NSMiniaturizableWindowMask|NSTitledWindowMask;
     _webWindow = [[NSWindow alloc] initWithContentRect:NSMakeRect(0, 0, 400, 300) styleMask:windowStyleMask backing:NSBackingStoreNonretained defer:YES];
     [_webWindow setReleasedWhenClosed:NO];
     WebView* newWebView = [[WebView alloc] initWithFrame:[_webWindow  contentRectForFrameRect:_webWindow.frame]];
    [newWebView setAutoresizingMask:NSViewWidthSizable|NSViewHeightSizable];
    [[newWebView mainFrame] loadRequest:request];
    [_webWindow setContentView:newWebView];
    [_webWindow center];
    [_webWindow makeKeyAndOrderFront:nil];
 
    return newWebView;
 
     }


      - (WebView *)webView:(WebView *)sender createWebViewModalDialogWithRequest:(NSURLRequest *)request{
 
    return [self webView:sender createWebViewWithRequest:request];
     }


    - (void)webViewRunModal:(WebView *)sender{
 
    [sender.window makeKeyAndOrderFront:self];
 
    }

    - (void)webViewShow:(WebView *)sender{
  
    [sender.window makeKeyAndOrderFront:self];
 
    }

    - (void)webViewClose:(WebView *)sender{
    [sender.window close];
    }

Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template