没有导航栏进行push(压栈)

如题

遇到这样一个需求  我这边是从登陆界面(无导航栏)压栈到其它界面  压栈后的界面有导航栏

代码如下

首先Appdelegate中代码

- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions {
    
    [self monitoringNetwork];
    ViewController *v = [[ViewController alloc]init];
    UINavigationController *nav = [[UINavigationController alloc]initWithRootViewController:v];
    self.window.rootViewController = nav;
    return YES;
}

然后ViewController中代码

- (void)viewDidLoad {
    [super viewDidLoad];
    self.navigationController.delegate = self;
    self.navigationController.interactivePopGestureRecognizer.delegate = self;
    self.edgesForExtendedLayout = UIRectEdgeNone;
    self.view.backgroundColor = [UIColor whiteColor];
    
    [self initUI];
    
}
- (void)navigationController:(UINavigationController *)navigationController willShowViewController:(UIViewController *)viewController animated:(BOOL)animated {
    
    if ([viewController isKindOfClass:[self class]]) {
        [navigationController setNavigationBarHidden:YES animated:YES];
    }else {
        [navigationController setNavigationBarHidden:NO animated:YES];
    }
}


这个是登陆界面push方法

#pragma mark  点击确定进入选择服务器地址界面
- (void)sureAction{
    
    
    UIBarButtonItem *backIetm = [[UIBarButtonItem alloc] init];
    backIetm.title = @"xxxx";
    self.navigationItem.backBarButtonItem = backIetm;
    SelectSiteController *s = [[SelectSiteController alloc]init];

    [self.navigationController pushViewController:s animated:YES];
}


注意  要遵循 UINavigationControllerDelegate , UIGestureRecognizerDelegate这两个代理  其中
self.navigationController.interactivePopGestureRecognizer.delegate = self;
该方法  是为了防止登陆界面添加了手势动作   返回时手势失效(我遇到了这个情况,这句代码就好了)





评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值