显示网络浏览器历史记录
我目前正在使用 webkit 框架在 Objective-C 中开发一个简单的、基于 cocoa 文档的 Web 浏览器。
我想添加一个窗口来显示浏览历史记录。我已经创建了带有文本框等的窗口,但我无法弄清楚如何在文本框中显示浏览历史记录。
请不要让我参考在线苹果开发者资源,因为我已经阅读过。
I am currently in the process of developing a simple, cocoa document based web browser in Objective-C, using the webkit framework.
I want to add a window to display the browsing history. I have created the window with a text box and all that, but I can not for the life of me figure how to display the browsing history in the textbox.
Please do not refer me to the apple developer resources online, as I have already read that.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
首先,您需要使用
setMaintainsBackForwardList:
启用 Web 视图的内置历史记录(如果您尚未这样做)。然后,您可以使用
backForwardList
方法访问浏览历史记录,该方法返回WebBackForwardList
类的对象。这不是一个简单的数组,因为它还需要在历史记录中维护一个位置,以防用户返回(以便能够再次前进)。要显示历史菜单或窗口,您可能对
backListCount
和backListWithLimit:
方法最感兴趣。后者返回WebHistoryItem
对象的NSArray
。这些方法有URLString
、title
、icon
和lastVisitedTimeInterval
。您可以使用这些方法来显示有关各个历史记录项目的信息。First of all, you need to enable the web view's built-in history with
setMaintainsBackForwardList:
, if you haven't already done so.You can then access the browsing history with the
backForwardList
method which returns an object of the classWebBackForwardList
.This isn't a simple array, because it also needs to maintain a position within the history, in case the user goes back (to be able to go forward again). To display a history menu or window, you're probably most interested in the
backListCount
andbackListWithLimit:
methods. The latter returns anNSArray
ofWebHistoryItem
objects. Those have the methodsURLString
,title
,icon
andlastVisitedTimeInterval
. You can use these methods to display information about the individual history items.