[英]Not Remove Navigation back button title
I am IOS Developer. 我是IOS开发人员。 I am using navigation controller.
我正在使用导航控制器。 If I push to next page then Back button title always Show "Back".
如果我按下到下一页,则返回按钮标题始终显示“返回”。 I try all this method for remove titles in viewWillAppear, viewDidload like below.
我尝试了所有这个方法来删除viewWillAppear中的标题,viewDidload如下所示。 But it is not working for me.
但这对我不起作用。
[[UIBarButtonItem alloc] initWithTitle:@""
style:UIBarButtonItemStylePlain
target:nil action:nil];
or 要么
[self.navigationItem.backBarButtonItem setTitle:@""];
or 要么
self.navigationItem.title=@"";
or 要么
self.navigationController.navigationBar.backItem.title =@"";
Thanks in advance. 提前致谢。
Swift 4 : 斯威夫特4 :
navigationItem.backBarButtonItem = UIBarButtonItem()
You can also do it in Storyboard, select your View Controller's Navigation Item, and set it's Back Button property to " " (one spacebar character). 您也可以在Storyboard中执行此操作,选择View Controller的导航项,并将其Back Button属性设置为“”(一个空格键字符)。
Both ways should be done on the View Controller you're segueing from. 两种方式都应该在您正在进行的视图控制器上完成。
Just try this, 试试吧,
[[UIBarButtonItem appearance] setBackButtonTitlePositionAdjustment:UIOffsetMake(0, -60)
forBarMetrics:UIBarMetricsDefault];
or use like this, 或使用这样的,
self.navigationItem.backBarButtonItem = [[UIBarButtonItem alloc] initWithTitle:@"" style:self.navigationItem.backBarButtonItem.style target:nil action:nil];
or use like this, 或使用这样的,
- (void)layoutSubviews{
self.backItem.title = @"";
[super layoutSubviews];
}
Swift 迅速
UIBarButtonItem.appearance().UIOffsetMake(0, -60)
or use like 或使用像
self.navigationItem.backBarButtonItem = UIBarButtonItem(title: "", style: self.navigationItem.backBarButtonItem.style, target: nil, action: nil)
For additional information, Please see [this].( UINavigationBar Hide back Button Text ) 有关其他信息,请参阅[this]。( UINavigationBar隐藏按钮文本 )
I think you only need to add an custom image for back button like this: 我认为您只需要为后退按钮添加自定义图像,如下所示:
UIBarButtonItem *backButton = [[UIBarButtonItem alloc] initWithImage:[UIImage imageNamed:@"header_back"]
style:UIBarButtonItemStylePlain
target:self
action:@selector(invokeButtonBack:)];
self.navigationItem.leftBarButtonItem = backButton;
with header_back
is your custom image for back button. with
header_back
是后退按钮的自定义图像。
If you using a custom base viewcontroller (maybe tableviewcontroller) simplify creat a function like this: 如果你使用自定义基本viewcontroller(也许是tableviewcontroller)简化creat这样的函数:
- (void)createBackButton{
UIBarButtonItem *backButton = [[UIBarButtonItem alloc] initWithImage:[UIImage imageNamed:@"header_back"]
style:UIBarButtonItemStylePlain
target:self
action:@selector(invokeButtonBack:)];
self.navigationItem.leftBarButtonItem = backButton;
}
Then call it in your viewcontroller with: [self createBackButton];
然后使用以下命令在viewcontroller中调用它:
[self createBackButton];
Hope my answer will help you. 希望我的回答能帮到你。
您需要在ViewDidLoad中添加以下行。
self.navigationController.navigationBar.topItem.title = @"";
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.