您可以手动向 iPhone/iPad 导航栏添加后退按钮项目吗?

发布于 2024-08-29 03:19:22 字数 709 浏览 1 评论 0原文

我引用了“UIBarButtonItem”,当该项目不属于基于导航的视图时,有没有办法向该项目添加自定义“后退导航按钮”?

我可以添加一个左侧按钮:

UIBarButtonItem *backButton = [[UIBarButtonItem alloc] 
initWithTitle:@"Custom Back" 
style:UIBarButtonItemStylePlain target:self
action:@selector(backAction:)];

menuItem.backBarButtonItem = backButton; //This doesn't seem to work.

menuItem.popOverNavigationItem.leftBarButtonItem = backButton; //This shows a normal button

那么如何使最左侧的按钮看起来像后退导航按钮呢?

更新:另一个问题回答了我的问题的根源,导致我尝试执行此非标准 UI 设置:
iPad:在RootView中合并SplitViewController和NavigationController的概念?

I have a reference to a "UIBarButtonItem", is there a way I can add a custom "Back Navigation Button" to that item when it is not part of a Navigation based view?

I can add a left button:

UIBarButtonItem *backButton = [[UIBarButtonItem alloc] 
initWithTitle:@"Custom Back" 
style:UIBarButtonItemStylePlain target:self
action:@selector(backAction:)];

menuItem.backBarButtonItem = backButton; //This doesn't seem to work.

menuItem.popOverNavigationItem.leftBarButtonItem = backButton; //This shows a normal button

So how could I make the leftmost button look like a back navigation button?

UPDATE: This other question answered the root of my problem that was leading me to try and do this non-standard UI setup:
iPad: Merge concept of SplitViewController and NavigationController in RootView?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

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

发布评论

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

评论(2

云裳 2024-09-05 03:19:22

我认为设置后退按钮的正确方法是将其设置为您要返回的视图控制器。例如:

RootViewController > DetailViewController

如果您希望在 DetailViewController 上时后退按钮显示“自定义后退”,则必须实际将 RootViewController 的后退按钮设置为“自定义后退”。

希望这是有道理的。

I think the correct way to set the back button is to set it for the view controller that you would be going back to. For example:

RootViewController > DetailViewController

If you want the back button to say "Custom Back" whilst you're on DetailViewController, you have to actually set RootViewController's back button to "Custom Back".

Hope that makes sense.

溺渁∝ 2024-09-05 03:19:22

刚刚为此苦苦挣扎:我认为答案是“不”。您将需要一个控制器层次结构。

Having just struggled with this: I think the answer is “no.” You'll need a controller hierarchy.

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