objective-c - UINavigationController 后退按钮中的自定义文本

标签 objective-c ios uinavigationcontroller

在我的应用程序中,我有 UINavigationController 和两个 UIViewControler(第一个和第二个)。第一个 View Controller 包含 UITableView。当触摸表格的单元格时,将推送第二个 View Controller 。我想要的是在第二个 View 中将自定义文本设置为后退按钮。这是第二个 View 中的代码。

- (void)viewDidLoad
{
   [super viewDidLoad];
    self.navigationItem.leftBarButtonItem =
    [[[UIBarButtonItem alloc] initWithTitle:@"Go back"
                                      style:UIBarButtonItemStyleBordered
                                     target:nil
                                     action:nil] autorelease]; 
}

问题是后退按钮的文本已更改,但触摸按钮时第二个 View Controller 并未从堆栈中移除。

最佳答案

这已经被问过很多次了:

必须设置后退按钮 (self.navigationItem.backBarButtonItem) 而不是左按钮,并且不是在第二个 Controller 中,而是在第一个 Controller (root)中。

关于objective-c - UINavigationController 后退按钮中的自定义文本,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/9776009/

相关文章:

ios - UIImagePickerController照片快门无法打开

iphone - distanceFromLocation 似乎不起作用

ios - UINavigationControllerDelegate 不起作用

iOS 如何在顶 View Controller 弹出时以编程方式检测?

ios - 如何在 iOS 7 上的 UINavigationController 中创建自定义后退滑动手势

ios - 限制 UIWebView 停留在 Facebook 页面上

ios - IOS 中的 Google Place Search API

iphone - 重写 NSObject 的描述方法

ios - 在后台线程中运行 NSTimer 以在主线程中完成时调用方法

ios - Xcode10.3 - Xib 无法拖放 UICollectionViewCell