gpt4 book ai didi

ios - 当推送到另一个 ViewController 时如何隐藏 UINavigationBar?

转载 作者:行者123 更新时间:2023-11-28 23:58:47 25 4
gpt4 key购买 nike

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

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

ViewController A

- (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];
}];
}
}

当前结果: enter image description here

最佳答案

请试试这个代码

- (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];
}];
}
}

关于ios - 当推送到另一个 ViewController 时如何隐藏 UINavigationBar?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/50265907/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com