gpt4 book ai didi

ios - 全屏 PushViewController

转载 作者:行者123 更新时间:2023-11-29 10:24:44 29 4
gpt4 key购买 nike

我想知道是否可以在没有标签栏和导航栏的情况下全屏推送 NavigationControllerViewController。我的问题如下:

我的应用在 TabBarController 中嵌入了一个 NavigationController。在 NavController 中,我显示了一个带有按钮的 FirstVC 以导航到另一个 VC。现在我做一个模态演示来显示 SecondVC。但是在这个 SecondVC 中,我有一个 tableview,其中一个按钮返回一个 ThirdVC。此ThirdVC 需要具有FirstVC 的导航栏和标签栏。也许我需要在第一个的 NavigationController 上按下来显示 SecondVC 但似乎我无法重现我的全屏动画 ...

为简单起见:

FirstVC ===> SecondVC (modal presentation) ====> ThirdVC (modal presentation):

这是我目前在 ThirdVC 上没有导航栏或标签栏的应用。

提前致谢。

编辑

SecondVC 的模态表示是这样的:

- (IBAction)detailButtonClicked:(id)sender {
SecondVC *vc = [self.storyboard instantiateViewControllerWithIdentifier:@"SecondVC"];
vc.modalPresentationStyle = UIModalPresentationFullScreen;
[self presentViewController:vc animated:YES completion:nil];
}

SecondVCThirdVC 我再次使用 presentViewController 因为我不能在模态中使用 pushViewController。结果是可以预见的:我没有导航栏或标签栏。

我尝试了不同的方法,例如下面的方法或将 addChildView 作为我的 FirstVC 的 subview :

- (IBAction)detailButtonClicked:(id)sender {
SecondVC *vc = [self.storyboard instantiateViewControllerWithIdentifier:@"SecondVC"];
UINavigationController *childNavigationController = [[UINavigationController alloc] initWithRootViewController:vc];
childNavigationController.navigationBarHidden = YES;
[self.navigationController presentViewController:childNavigationController animated:YES completion:nil];
}

并且在 SecondVC

- (IBAction)changeButtonClicked:(id)sender {
ThirdVC *vc = [self.storyboard instantiateViewControllerWithIdentifier:@"ThirdVC"];
[self.navigationController pushViewController:vc animated:YES];
}

我也无法访问 ThirdVC 中的标签栏或导航栏...

最佳答案

我在您的代码中所做的是添加以下代码改进。

- (IBAction)buttonClicked:(id)sender {
UIStoryboard *mainStoryboard = [UIStoryboard storyboardWithName:@"Main"
bundle: nil];
SecondViewController *vc = (SecondViewController*)[mainStoryboard
instantiateViewControllerWithIdentifier: @"SecondVC"];
vc.delegate = self;

[[APP_DELEGATE window] addSubview:vc.view];
[self addChildViewController:vc];
}

主要代码是addchildViewController

Here You can download the sample code of yours.

关于ios - 全屏 PushViewController,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/32990754/

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