如何在推送到另一个 ViewController 时隐藏 UINavigationBar?

How to hide UINavigationBar when push to another ViewController?

我有一个 ViewController、"ViewController A",我想推送到另一个 ViewController、"ViewController B"。当我推送到 ViewController B 时,我将检查用户验证并在用户不是有效用户时显示弹出警报。

如何隐藏 UINavigationBar,因为我当前的代码无法正常工作。请帮忙。谢谢!

ViewController一个

- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath {
    [tableView deselectRowAtIndexPath:indexPath animated:YES];

    if(indexPath.row==0) //Wishlist
    {
            WishList_ViewController *WishList_ViewControl = [[WishList_ViewController alloc]init];
           // [self cw_presentViewController:WishList_ViewControl];
         [self cw_pushViewController:WishList_ViewControl];
    }
}

ViewController B

- (void)viewDidLoad {
    [super viewDidLoad];
    self.navigationItem.title = @"My Wishlist";

    if (![[NSUserDefaults standardUserDefaults] boolForKey:@"isLogin"])
    {
        //THIS CODE DOES NOT WORKING
        [self.navigationController setNavigationBarHidden:YES animated:YES];

        //Check whether is login or not
        SCLAlertView *alert = [[SCLAlertView alloc] init];
        [alert addButton:@"Done" target:self selector:@selector(btnLoginClick:)];
        alert.customViewColor = ThemeBlueColor;
        [alert showWaiting:self title:@"Login" subTitle:@"Please login to view your wishlist"
          closeButtonTitle:nil duration:2.0f ];

        [alert alertIsDismissed:^{
            [self btnLoginClick:nil];
        }];
    }
}

当前结果:

请试试这个代码

- (void)viewDidLoad {
    [super viewDidLoad];
    self.navigationItem.title = @"My Wishlist";

    if (![[NSUserDefaults standardUserDefaults] boolForKey:@"isLogin"])
    {

        self.navigationController.navigationBar.hidden=YES;

        //Check whether is login or not
        SCLAlertView *alert = [[SCLAlertView alloc] init];
        [alert addButton:@"Done" target:self selector:@selector(btnLoginClick:)];
        alert.customViewColor = ThemeBlueColor;
        [alert showWaiting:self title:@"Login" subTitle:@"Please login to view your wishlist"
          closeButtonTitle:nil duration:2.0f ];

        [alert alertIsDismissed:^{
            [self btnLoginClick:nil];
        }];
    }
}