您可以手动向 iPhone/iPad 导航栏添加后退按钮项目吗?
我引用了“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 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
我认为设置后退按钮的正确方法是将其设置为您要返回的视图控制器。例如:
如果您希望在 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:
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.
刚刚为此苦苦挣扎:我认为答案是“不”。您将需要一个控制器层次结构。
Having just struggled with this: I think the answer is “no.” You'll need a controller hierarchy.