iOS 7 backBarButtonItem hidden

2019-06-20 05:22发布

问题:

I've an issue with back bar button. It stay hidden no matter that i do like self.navigationItem.hidesBackButton

Here is my code to add back button:

//
    - (void)viewDidLoad{

    [.....];

    UIBarButtonItem *back = [[UIBarButtonItem alloc] initWithTitle:NSLocalizedString(@"UI_BTN_BACK", nil) style:UIBarButtonItemStylePlain target:nil action:nil];
    back.tintColor = [Templates getColor:@"color"];
    [[self navigationItem] setBackBarButtonItem:back];

    // Parent
    [super viewDidLoad];
}

Button stay hidden BUT going back works if if touch on the place where it should be. Of course it works on iOS6. Another detail: back button seems to appear when i set UINavigationBar translucent to YES.

Thanks

回答1:

Use this code:

self.navigationItem.backBarButtonItem = nil;

OR

self.navigationItem.leftBarButtonItem = nil;


回答2:

[self.navigationItem setHidesBackButton:YES];

Check out this.



回答3:

self.navigationController.navigationBar.tintColor = [UIColor whiteColor];