iOS 8:UINavigationController隐藏后退按钮 [英] iOS 8: UINavigationController hide back button

查看:503
本文介绍了iOS 8:UINavigationController隐藏后退按钮的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在iOS 8(XCode 6.0.1,iPhone 6)中运行我的应用程序后,后退按钮不会隐藏。

After I run my application in iOS 8 (XCode 6.0.1, iPhone 6), the back button does not hide.

我的代码:

- (void)removeCategoriesButton
{
    if (UI_USER_INTERFACE_IDIOM() == UIUserInterfaceIdiomPhone) {
        [_navigationController.topViewController.navigationItem setHidesBackButton:YES];
        [_navigationController.topViewController.navigationItem setLeftBarButtonItem:nil];
    } else {
        UIViewController *controller = _app.window.rootViewController;

        if ([controller isKindOfClass:[UINavigationController class]]) {
            UINavigationController *nav = (UINavigationController *)controller;
            [nav.topViewController.navigationItem setHidesBackButton:YES];
            [nav.topViewController.navigationItem setLeftBarButtonItem:nil];
        }
    }
}

但后退按钮没有hide(见截图):

But the back button does not hide (see screenshot):

UPD:

我在其他模拟器中运行应用程序,我看到这个错误只在iOS 8上。

I run application in another simulators, and i see this "bug" only on iOS 8.

推荐答案

这对我有用。

-(void)viewWillAppear:(BOOL)animated {

    [super viewWillAppear:animated];

    [self.navigationItem setHidesBackButton:YES];
    [self.navigationItem setTitle:@"Home"];
}

这篇关于iOS 8:UINavigationController隐藏后退按钮的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆