You’ll have to build this history yourself, using a delegate callback from the web view to learn about user actions. If you’re using WKWebView (which you should be, it’s the future of web views on our platforms), you do this via the navigation delegate (WKNavigationDelegate).

Edit: I posted a link to some old documentation. I'm pretty sure the basic walk through of how to use the WK WebKit classes has been covered in recent WWDC video sessions. That would be where to start if you need a walk through.

But i have another problem with the cangoback ,cangoforward and WKBackforwardlist. I'm not able to enable the back button properly ,also the forward button. And I'm not able to set the WKBackforwardlist in a table view.

Thank you very much for you help..About the WKBackforwardlist in a table view, I have created another view controller for the bookmarks(history) and assign the bookmarks button of a toolbar to it. Should I create a subview instead of another view controller ? and I don't know how to link the tableview.dataSource with the WKBackforwardlist

I have created another view controller for the bookmarks(history) and assign the bookmarks button of a toolbar to it. Should I create a subview instead of another view controller ?

You probably want to use a view controller no matter what. The key question is, how do you present that view controller? And that depends on the UI you want. For example, in Safari on iPhone the history is presented modally, whereas on iPad it’s contained with the main view (presumably via some sort of view controller containment).

If you need help with these you should really ask over in the Cocoa Touch topic area; there’s nothing web view specific about them.

I don't know how to link the tableview.dataSource with the WKBackforwardlist

Conceptually a WKBackForwardList represents two arrays, the forward list (forwardList) and the back list (backList). Each of these contains items of type WKBackForwardListItem that have information about that particular navigation (the title, the URL, and so on). For history you only really care about the back list. Presenting such an array of items in a table view is a pretty straightforward task.

I have two view controllers, one with the WKWebview and the second one with a table view. How can I call on the second view controller, the WebView.backforwardlist?

Normally you’d do this via dependency inject or delegation, but it’s hard to give concrete advice without knowing more about how those view controllers are related. Are they peers? Or is one subordinate to the other (for example, by being presented modally)?

OK, so the bookmarks view controller is presented on the web view controller. In that case the web view controller can inject a reference to the WKBackForwardList object into the bookmarks view controller just before it presents it (betweens lines 3 and 4 in your code snippet).

The basic idea is for the ‘parent’ view controller to give the ‘child’ view controller a reference to the model object that the child should display. In this case you can have the child define a forwardBackList property of type WKBackForwardList, and then have the parent set that property to the web view’s forward/back list just before it presents the child.

More Like This

Retrieving data ...

This site contains user submitted content, comments and opinions and is for informational purposes only. Apple disclaims any and all liability for the acts, omissions and conduct of any third parties in connection with or related to your use of the site. All postings and use of the content on this site are subject to the Apple Developer Forums Participation Agreement.