繁体   English   中英

如何从AppDelegate隐藏导航栏后退按钮标题

[英]How to hide Navigation Bar back button title from AppDelegate

每当我的应用程序收到带有自定义有效负载的推送通知时,我都希望将其推送到UIViewController ,就可以做到,但是我无法从AppDelegateUINavigationBar的“后退”按钮中删除标题。

我试过的是:

    [self.window.rootViewController.navigationController setNavigationBarHidden:NO];
    [self.window.rootViewController.navigationController.navigationBar setBackgroundImage:[UIImage new] forBarMetrics:UIBarMetricsDefault];
    [self.window.rootViewController.navigationController.navigationBar setShadowImage:[UIImage new]];
    [self.window.rootViewController.navigationController.navigationBar setTranslucent:YES];
    [self.window.rootViewController.navigationController.navigationBar setTintColor:[UIColor mainBlue]];
    self.window.rootViewController.navigationItem.backBarButtonItem = [[UIBarButtonItem alloc] initWithTitle:@"" style:self.window.rootViewController.navigationItem.backBarButtonItem.style target:nil action:nil];

最后一行是我将后退按钮的标题设置为nil但是它不起作用,当UIViewController可见时,我仍然可以选择标题。 如果在该代码之前在UIViewController上使用它,但不在AppDelegate上使用,则该代码有效。 有没有人有办法解决吗? 我究竟做错了什么?

[[UIBarButtonItem appearance] setBackButtonTitlePositionAdjustment:UIOffsetMake(0, -60) forBarMetrics:UIBarMetricsDefault];

这将从所有导航项中隐藏后退按钮标题。 您应该根据标题长度更改偏移值。

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM