ios - 无法覆盖导航按钮 UICollectionViewController

标签 ios

我有一个 UICollectionViewController,它就像一个分页,每个单元格都有自己的页面。 在导航栏上,它始终显示“返回”。 以下不会更改标题。

-(void)viewWillAppear:(BOOL)animated{
UIBarButtonItem *backButton = [[UIBarButtonItem alloc]
                               initWithTitle: @"Back Button Text"
                               style: UIBarButtonItemStyleBordered
                               target: nil action: nil];

[self.navigationItem setBackBarButtonItem: backButton];

最佳答案

您需要使用此代码:

self.navigationItem.backBarButtonItem = [[UIBarButtonItem alloc] initWithTitle:@"Custom Title"
        style:UIBarButtonItemStyleBordered
       target:nil
       action:nil];

请注意,您需要在后退按钮将指向的 View Controller 上进行设置。例如,如果 ViewControllerA 按下 ViewControllerB 到导航堆栈,然后您将在 ViewControllerA 上使用此代码。

关于ios - 无法覆盖导航按钮 UICollectionViewController,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/16224682/

相关文章:

ios - 转换矩形 :toView doesn't return expected window coordinates

ios - 设置是否没有观察模型属性的变化 - Swift

ios - 添加资源路径到 UIWebView Cordova IOS

Objective-C 编码指南

ios - TableView仅在单击时显示内容

ios - 如果 UIView 没有 superview,它的frame 属性会变成什么?

ios - Google Places iOS - 应用程序太大

ios - 在初始化时向 UIView 添加 subview

ios - swift 。在后台运行异步下载并让用户与 UI 交互

iOS:Firebase 和 facebook 帐户工具包登录