在self.navigationController.viewcontroller堆栈之间插入ViewController [英] inserting ViewController In between the stack of self.navigationController.viewcontroller

查看:85
本文介绍了在self.navigationController.viewcontroller堆栈之间插入ViewController的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我的导航控制器中有3个Viewcontollers.现在我要做的只是在self.navigationController.viewControllers数组之间插入一个视图控制器.

I have three viewcontollers in my navigation controller. Now what i want to do just insert a view controller in between the array of self.navigationController.viewControllers.

当我检查属性viewControllers不是只读属性时,我想我们也可以对其进行设置. 那就是为什么我使用下面的代码在堆栈之间插入ViewController的原因. 但不幸的是,它不会修改 self.navigationController.viewControllers的堆栈.

As I checked the property viewControllers is not a readonly property So i think we can set it also. thats why I used the below code to insert my ViewController in between the stack. But unfortunately it doesn't modify the stack of self.navigationController.viewControllers.

因此,我该如何插入和修改堆栈.另外,请确保我不想使用pushViewcontroller.

    CXSTransactionSelectionViewController *trxSelectionVc = [self.storyboard instantiateViewControllerWithIdentifier:@"CXSTransactionSelectionViewController"];
    NSMutableArray *viewControllers = [self.navigationController.viewControllers mutableCopy];
    [viewControllers insertObject:trxSelectionVc atIndex:viewControllers.count-2 ];
    [self.navigationController setViewControllers:viewControllers animated:YES];
    NSLog(@"%@",self.navigationController.viewControllers);

推荐答案

使用此解决了我的问题

CXSTransactionSelectionViewController *trxSelectionVc = [self.storyboard instantiateViewControllerWithIdentifier:@"CXSTransactionSelectionViewController"];
[self.navigationController.viewControllers insertObject:trxSelectionVc atIndex:1 ];
NSLog(@"%@",self.navigationController.viewControllers);

这篇关于在self.navigationController.viewcontroller堆栈之间插入ViewController的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆