Webview 的 goToItem 没有做任何事情?

发布于 2025-01-04 10:21:07 字数 587 浏览 4 评论 0原文

我目前正在尝试为我的浏览器设置一个漂亮的后退按钮上下文菜单。它使用 -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 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

檐上三寸雪 2025-01-11 10:21:07

好吧,我最终弄清楚了。结果我需要使用 [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:].

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文