ios - 全屏 PushViewController

标签 ios objective-c modalviewcontroller pushviewcontroller

我想知道是否可以在没有标签栏和导航栏的情况下全屏推送 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/

相关文章:

ios - 从 JSON 转换时,NSArray 包含一个缺少引号的字符串?

ios - 通过 iOS 将用户和密码发送到网页

ios - 如何通过底部中心旋转图像?

javascript - 单击时无法打开模态表单

objective-c - 解除ModalViewController动画之谜

ios - 有没有办法通过按钮操作将用户发送到设置中的推送通知部分?

ios - 写入上一个 Realm 对象而不是下一个

ios - iOS应用程序中的youtube iFrame在全屏后导致半屏变黑

objective-c - ipad编程指导

objective-c - 当呈现的模态视图 Controller 被解除时,从主视图 Controller 知道吗?