ios - 从当前上下文推送导航

标签 ios objective-c uinavigationcontroller presentviewcontroller

嗨,我有两个 Viewcontroller 一个 我正在介绍来自 的 Controller 一个 Controller 与 当前上下文 我在下面粘贴了我的编码。我想从 推送乙 Controller 到 中号 Controller ,我知道当我们展示时没有分配导航 Controller ,如果我展示带有 rootviewcontroller 的导航 Controller ,我无法获得透明的结果。

 UIStoryboard *story = [UIStoryboard storyboardWithName:@"Main" bundle:[NSBundle mainBundle]];
        ChooseAddressVc *sec=[story instantiateViewControllerWithIdentifier:@"ChooseAddressVc"];
        sec.myDelegate = self;
        sec.modalPresentationStyle = UIModalPresentationOverCurrentContext;
        sec.modalTransitionStyle = UIModalTransitionStyleCoverVertical;
        [self presentViewController:sec animated:YES completion:^{

        }];

从 View Controller B 推送到 C
UIStoryboard*Story=[UIStoryboard storyboardWithName:@"Main2" bundle:nil];
    AddNewAddressVc*choose=[Story instantiateViewControllerWithIdentifier:@"AddNewAddressVc"];
    [self.navigationController pushViewController:choose animated:YES];

注意:当我呈现当前上下文时,我需要从 B Controller 推送到 C Controller 。 为了更好地理解 : 当我们需要获得透明效果时,我们无法将导航 Controller 分配为 Root View Controller

最佳答案

在你的情况下self.navigationController在 B View Controller 中为零。您需要创建 UINavigationController B View Controller 为 rootViewController .礼物创建UINavigationController从 A 而不是呈现 B View Controller ,之后您可以使用 self.navigationController在 B View Controller 中。

您的代码已编辑:

    UIStoryboard *story = [UIStoryboard storyboardWithName:@"Main" bundle:[NSBundle mainBundle]];
    ChooseAddressVc *sec=[story instantiateViewControllerWithIdentifier:@"ChooseAddressVc"];
    sec.myDelegate = self;

    UINavigationController *navController = [[UINavigationController alloc] initWithRootViewController:sec];
    navController.modalPresentationStyle = UIModalPresentationOverCurrentContext;
    navController.modalTransitionStyle = UIModalTransitionStyleCoverVertical;

    [self presentViewController:navController animated:YES completion:^{

    }];

关于ios - 从当前上下文推送导航,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/43498030/

相关文章:

iphone - iOS - 更改 masterViewController 的大小

iphone - 从 UITextField 输入动态调整 UITableView 大小

ios - UITableView 行选择故障?

iOS - 是否可以在设备旋转时仅旋转导航栏按钮?

iphone - 当 View Controller 导航到另一个 View Controller 时,事件指示器未开始动画

iphone - 更改导航栏的字体

ios - 如何检测是否安装了 NEVPNManager 配置?

ios - 在后台线程上下载图像时锁定核心数据

c++ - 从服务器发送推送通知

使用 ZBarSDK 时 iPhone 相机失去自动对焦