Webview 的 goToItem 没有做任何事情?
我目前正在尝试为我的浏览器设置一个漂亮的后退按钮上下文菜单。它使用 -backListWithLimit 提供的数组中的项目填充自身,并包含项目标题和图标。每个项目都将其representedObject 设置为其各自的WebHistoryItem,并将其操作设置为goToHistoryItem:,这是我的一个方法,它获取发送者的representedObject 并尝试告诉主webView 导航到该历史记录项。代码如下:
- (IBAction)goToHistoryItem:(id)sender
{
WebHistoryItem *historyItem = [sender representedObject];
[[mainWebView backForwardList] goToItem:historyItem];
}
菜单呈现完美,每个项目都有适当的标题和标记。但由于某种原因,选择一个项目根本就失败了。我已经检查过 NSLog,并且 WebHistoryItem 正在传递...... webView 不会用它做任何事情。它没有留下任何错误,没有控制台日志,什么都没有,而且我不知道哪里出了问题。
我在这里错过了什么吗?为什么这不起作用?
I'm currently trying to set up a nice back button contextual menu for my browser. It populates itself with items from the array provided by -backListWithLimit, complete with item titles and icons. Each item has its representedObject set to its respective WebHistoryItem and its action set to goToHistoryItem:, a method of mine which grabs the sender's representedObject and attempts to tell the main webView to navigate to that history item. Here's the code:
- (IBAction)goToHistoryItem:(id)sender
{
WebHistoryItem *historyItem = [sender representedObject];
[[mainWebView backForwardList] goToItem:historyItem];
}
The menu renders perfectly, with each item appropriately titled and badged. For some reason, though, selecting an item simply fails. I've checked with NSLog, and the WebHistoryItem IS getting passed along… the webView just won't do anything with it. It leaves no error, no console log, nothing, and I can't figure out where I've gone wrong.
Am I missing something here? Why doesn't this work?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
好吧,我最终弄清楚了。结果我需要使用 [webView goToBackForwardItem:] 而不是 [[webView backForwardList] goToItem:]。
Well, I ended up figuring it out. Turns out I needed to use [webView goToBackForwardItem:] instead of [[webView backForwardList] goToItem:].