gpt4 book ai didi

ios - 在 Navigation Bar 右侧添加 goBack 和 goForward

转载 作者:行者123 更新时间:2023-11-28 22:24:22 25 4
gpt4 key购买 nike

我有一个 WebviewViewController 和一个带有后退栏按钮的导航栏。现在我想要在栏的右侧有两个按钮,一个 goBack 和一个 goForward。我已经搜索了一段时间,但没有一个答案是正确的。

有一种方法可以将它们添加到 Storyboard 中或仅以编程方式添加?如果可以,我该怎么做?

最佳答案

我以前做过,很简单:

myBackBarButton = [[UIBarButtonItem alloc] initWithImage:barButtonImage
style:UIBarButtonItemStylePlain
target:myWebView
action:@selector(goBack)];

myForwardButtom = [[UIBarButtonItem alloc] initWithImage:anotherBarButtonImage
style:UIBarButtonItemStylePlain
target:myWebView
action:@selector(goForward)];

myWebView 是您的 UIWebView(如果是您的类(class),请使用 self)

如果您的按钮已经创建,则只需向它们添加目标和操作:

myBackButton.target = myWebView;
myBackButton.action = @selector(goBack);

您正在做的是将 Action goForward: 和 goBack: 添加到这些按钮中,目标是您的 webview。

关于ios - 在 Navigation Bar 右侧添加 goBack 和 goForward,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/19401683/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com