Tuesday, 13 June 2017

WKWebView open external links

if u want to open in same window
- (WKWebView *)webView:(WKWebView *)webView createWebViewWithConfiguration:(WKWebViewConfiguration *)configuration forNavigationAction:(WKNavigationAction *)navigationAction windowFeatures:(WKWindowFeatures *)windowFeatures { 
  if (!navigationAction.targetFrame.isMainFrame) {
    [UIApplication sharedApplication].networkActivityIndicatorVisible = YES; 
[self.webView loadRequest:navigationAction.request]; 
} 
return nil;
}

or if u want to open in popup. create new wkwebview and add to parent view.


-(WKWebView *)webView:(WKWebView *)webView createWebViewWithConfiguration:(WKWebViewConfiguration *)configuration forNavigationAction:(WKNavigationAction *)navigationAction windowFeatures:(WKWindowFeatures *)windowFeatures{

       self.popWindow =[[WKWebView alloc] initWithFrame:CGRectMake(25, 25,             self.view.frame.size.height - 6, self.view.frame.size.width -94) configuration:configuration];
      _popWindow.navigationDelegate = self;
      _popWindow.UIDelegate = self;
      [wkWebView addSubview:_popUpView];
return _popWindow;

}

No comments:

Setting Up Multiple App Targets in Xcode from a Single Codebase

 To create two different apps (like "Light" and "Regular") from the same codebase in Xcode, you can follow these steps b...