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

时间:2016-05-10 13:05:40

标签: ios objective-c

每当我的应用收到带有自定义有效负载的推送通知时,我想将应用推送到UIViewController,我就可以执行此操作,但我无法从{{1的后退按钮中删除标题来自UINavigationBar

我尝试的是:

AppDelegate

最后一行是我将后退按钮的标题设置为 [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,则代码可以使用。有没有人有办法解决吗?我做错了什么?

1 个答案:

答案 0 :(得分:2)

- (void)handleAudioSessionInterruption:(NSNotification*)notification {

    NSNumber *interruptionType = [[notification userInfo] objectForKey:AVAudioSessionInterruptionTypeKey];
    NSNumber *interruptionOption = [[notification userInfo] objectForKey:AVAudioSessionInterruptionOptionKey];

    switch (interruptionType.unsignedIntegerValue) {
        case AVAudioSessionInterruptionTypeBegan:{
            // • Audio has stopped, already inactive
            // • Change state of UI, etc., to reflect non-playing state
            NSLog(@"AVAudioSessionInterruptionTypeBegan");

        } break;
        case AVAudioSessionInterruptionTypeEnded:{
            // • Make session active
            // • Update user interface
            // • AVAudioSessionInterruptionOptionShouldResume option
            NSLog(@"AVAudioSessionInterruptionTypeEnded");
            if (interruptionOption.unsignedIntegerValue == AVAudioSessionInterruptionOptionShouldResume) {
                // Here you should continue playback.
            }
        } break;
        default:
            break;
    }
}

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