本文介绍了导航栏上的自定义后退按钮的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述 29岁程序员,3月因学历无情被辞! 在我的应用程序中,有许多 UIViewControllers ,带有 UINavigationControllers 。 UINavigationBar 上必须有一个后退按钮和一个主页 UIButton 。所有这一切都很好。In my application there are many UIViewControllers with UINavigationControllers. There must be a "back" button and a "home" UIButton on the UINavigationBar. All of this works fine.但我的一些 UIViewControllers 有很长的名字,有时候地方太小了离开了。我正在尝试用自定义后退替换后退按钮的原始标签(它显示上一个视图的标题),但无论我尝试过什么都不起作用:But some of my UIViewControllers have long names, and sometimes there is too small place left for it. I'm trying to replace the original label of the "back" button (it shows the title of the previous view) with a custom "Back", but whatever I tried it didn't work:// Title didn't change[self.navigationItem.backBarButtonItem setTitle:@"Back"];// Action didn't set, no response from button ( button didn't do anything )[self.navigationItem.leftBarButtonItem setAction:self.navigationItem.backBarButtonItem.action];我需要后退按钮才能有这样的风格: 在iPhone导航栏上绘制自定义后退按钮And I need the "back" button to have a style like in this question: Draw custom Back button on iPhone Navigation Bar推荐答案试试这个UIBarButtonItem *backBarBtnItem = [[UIBarButtonItem alloc] initWithTitle:@"Back" style:UIBarButtonItemStylePlain target:self action:@selector(popViewController)];[self.navigationItem setBackBarButtonItem:backBarBtnItem];- (void)popViewController{ [self.navigationController popViewControllerAnimated:YES];} 这篇关于导航栏上的自定义后退按钮的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持! 上岸,阿里云! 09-04 22:07