1

I am trying to use WKWebView to create a mobile web browser for a website.

The main problem with the website is it's made up of one main frame (login page) then a bunch of subframes. I'm trying to use a WKNavigationDelegate to track each page that opens, but it only works on the main frame and can't track the subframes.

Is there a way around this issue, or a different tool I should be using? Thanks in advance.

  • Hi - what are you trying to accomplish with these frames? Are you just wanting to be alerted when a frame opens, or evalutate javascript, or...? – mattsven Oct 07 '18 at 20:48
  • When navigating from one subframe to another, the screen format doesn't reload (ex: if you zoom in on one page, it will stayed zoomed when you go to a new page). I'm looking to detect every time a new subframe loads so I can reformat the screen. – Blair Myers Oct 08 '18 at 14:55
  • I see. So was @Asleepace's answer sufficient? – mattsven Oct 08 '18 at 20:47

1 Answers1

0

Look at implementing this method:

optional func webView(_ webView: WKWebView, 
      decidePolicyFor navigationAction: WKNavigationAction, 
      decisionHandler: @escaping (WKNavigationActionPolicy) -> Void)

The navigationAction has a property isMainFrame that specifies if the current request is on the main frame, or a subframe.

You can read more about it here.

Asleepace
  • 3,466
  • 2
  • 23
  • 36