ios7-警告:在进行演示时尝试在UINavigationController上呈现UINavigationController [英] ios7 - Warning: Attempt to present UINavigationController on UINavigationController while a presentation is in progress

查看:53
本文介绍了ios7-警告:在进行演示时尝试在UINavigationController上呈现UINavigationController的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在didSelectRowAtIndexPath中选择一个序列时,出现上述警告.这是在iPad上发生的. iPhone发出了不同的警告,我将看看对此的修复是否还可以解决其他问题.

I'm getting the warning above when selecting a segue in didSelectRowAtIndexPath. This is happening on an iPad. The iPhone gives a different warning, and I'll see if a fix to this also fixes the other.

我确实有两种方法.最初的工作没有任何意外.第二个拿起警告.我在网上四处张望,并查看了其他人的解决方案.娜达,所以我要在这里发布..

I do have two segues in the method. The first works without incident. The second picks up the warning. I've looked around the net, and checked out others' solutions. nada, so I'm posting here..

下面是代码:(我愿意采用更好的方式编写此代码!)

Here's the code: (I'm open to better ways to write this!)

-(void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath {
    //NSLog(@"%s", __FUNCTION__);

    if ((indexPath.section == 0) || (indexPath.section == 1) || (indexPath.section == 2)) return;
    if (indexPath.section > 4) return;

    //Images THIS WORKS OK
    if (indexPath.section == 3 && indexPath.row == 0) { 
        viewController1 = [[ViewController1 alloc] init];
        [self performSegueWithIdentifier:@"detailToV1" sender:self];
        [self.tableView reloadData];
    }

    if (indexPath.section == 3 && indexPath.row == 1) { // THIS REDULTS IN A WARNING
        viewController2 = [[ViewController2 alloc] init];
        [self performSegueWithIdentifier:@"detailToV2" sender:nil];
    }

//Notes THIS WORKS OK BUT I HAD TO USE A NIB TO AVOID THE WARNING
    if (indexPath.section == 4 && indexPath.row == 0) { 

        viewController3 = [[ViewController3 alloc] init];
        [[self navigationController] pushViewController:viewController3 animated:YES];
        [self.tableView reloadData];

    }
}

推荐答案

ViewController3的父类是什么?听起来像是一个导航控制器,据我了解,您不能从另一个导航控制器中推入一个导航控制器.如果您想执行类似的操作,则需要从第一个导航控制器中展示新的导航控制器.

What is the parent class of ViewController3? It sounds like it is a navigation controller, and it is my understanding that you cannot push a navigation controller from within another navigation controller. If you want to do something like that you'd need to present the new navigation controller from the first navigation controller.

基本上,如果您使用导航视图控制器推送另一个视图控制器,则该新视图控制器将保留在导航视图控制器内部". (导航VC具有同时管理多个VC的逻辑.)我认为,存在一个规则,即任何导航VC都不能位于"另一个导航VC中.因此,您只需要简单地回到常规VC演示文稿上,以使新的导航VC不在原始导航VC的内部".它实际上不是位于其内部,而是位于其顶部.

Basically, if you use a navigation view controller to push another view controller, that new view controller remains "inside" the navigation view controller. (The navigation VC has logic to manage several VCs at once.) I believe there is a rule that no navigation VC can be "inside" another navigation VC. So you need to simply fall back on orindary VC presentation so that the new navigation VC is not "inside" the original navigation VC. Instead of being inside of it, it will essentially be on top of it.

代码示例:

[self.navigationController presentViewController:ViewController3 animated:YES completion:nil]

这篇关于ios7-警告:在进行演示时尝试在UINavigationController上呈现UINavigationController的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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