Ios 对…-UIViewController包含的开始/结束外观转换的不平衡调用

Ios 对…-UIViewController包含的开始/结束外观转换的不平衡调用,ios,uiviewcontroller,uinavigationcontroller,uikit,uitabbarcontroller,Ios,Uiviewcontroller,Uinavigationcontroller,Uikit,Uitabbarcontroller,好的,苹果在iOS5中引入了视图控制器容器(棒极了!) 上面是我的应用程序层的外观。TabBar包含NavController包含ViewController(容器),其中包含两个表视图,由分段控件切换 当我选择一个表格单元格时,它可以轻松地推送新视图。但是,如果我按下detailViewController中的按钮,我希望它以模式显示MFMailComposeViewController。它会短暂地自我呈现,然后立即自我否定。我得到的错误日志是: UITabBarController开始/结束

好的,苹果在iOS5中引入了视图控制器容器(棒极了!)

上面是我的应用程序层的外观。TabBar包含NavController包含ViewController(容器),其中包含两个表视图,由分段控件切换

当我选择一个表格单元格时,它可以轻松地推送新视图。但是,如果我按下detailViewController中的按钮,我希望它以模式显示MFMailComposeViewController。它会短暂地自我呈现,然后立即自我否定。我得到的错误日志是:

UITabBarController开始/结束外观转换的调用不平衡

- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath
{
    MenuFoodDetailViewController *menuFoodDetailViewController = [[MenuFoodDetailViewController alloc] initWithNibName:nil bundle:nil];
    //MenuFoodDetailViewController *menuFoodDetailViewController = [[MenuFoodDetailViewController alloc] init];

    [self.parentViewController.navigationController pushViewController:menuFoodDetailViewController animated:YES];
    [tableView deselectRowAtIndexPath:indexPath animated:NO];
}
现在,这意味着我试图在另一个视图仍在显示或处于运行时循环时显示视图,我尝试添加延迟来停止此操作,但没有任何效果。我添加了我的所有代理,并正确导入了我的所有库

我认为这可能与我如何从原始tableview推送新视图或如何将视图加载到容器中有关。正如您所知,该项目使用Xcode选项卡栏应用程序模板的基本代码。代码如下:

视图控制器/容器

- (void)viewDidLoad
{
    [super viewDidLoad];

    // Alloc Init View Controllers
    menuDrinksViewController = [[MenuDrinksViewController alloc] init];
    menuFoodViewController = [[MenuFoodViewController alloc] init];

    // Create Parent/Child relationship
    [menuFoodViewController didMoveToParentViewController:self];
    [self addChildViewController:menuFoodViewController];

    [menuDrinksViewController didMoveToParentViewController:self];
    [self addChildViewController:menuDrinksViewController];

    [appearanceClass setBackgroundImage:self.view];

    // segmented controller
    segmentedControl = [[SVSegmentedControl alloc] initWithSectionTitles:[NSArray arrayWithObjects:@"              Eat              ", @"               Drink               ", nil]];
    [segmentedControl addTarget:self action:@selector(segmentAction:) forControlEvents:UIControlEventValueChanged];
    [appearanceClass setSegmentedControl:segmentedControl];
    [self.view addSubview:segmentedControl];

    //self.view.backgroundColor = [UIColor redColor];

    // Add and Size subviews
    [self.view addSubview:menuFoodViewController.view];
    menuFoodViewController.view.frame = CGRectMake(0, 39, 320, self.view.frame.size.height - 40 + 1);
    menuDrinksViewController.view.frame = CGRectMake(0, 39, 320, 327 + 1);
}


-(IBAction)segmentAction:(id)selector
{
    // it's a custom segmented control, dw bout the code.
    if (segmentedControl.selectedIndex == 0)
    {
        [self.view addSubview:menuFoodViewController.view];
        [menuDrinksViewController.view removeFromSuperview];
    }
    else if (segmentedControl.selectedIndex == 1)
    {
        [self.view addSubview:menuDrinksViewController.view];
        [menuFoodViewController.view removeFromSuperview];
    }

}
TableViewController

- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath
{
    MenuFoodDetailViewController *menuFoodDetailViewController = [[MenuFoodDetailViewController alloc] initWithNibName:nil bundle:nil];
    //MenuFoodDetailViewController *menuFoodDetailViewController = [[MenuFoodDetailViewController alloc] init];

    [self.parentViewController.navigationController pushViewController:menuFoodDetailViewController animated:YES];
    [tableView deselectRowAtIndexPath:indexPath animated:NO];
}
按钮按详图视图控制器中的代码

- (void)showMailComposer
{
    // attempt to delay the presentModalView call, doesnt work...
    double delayInSeconds = 0.1;
    dispatch_time_t popTime = dispatch_time(DISPATCH_TIME_NOW, delayInSeconds * NSEC_PER_SEC);
    dispatch_after(popTime, dispatch_get_main_queue(), ^(void){
        [self.navigationController presentModalViewController:mailComposeViewController animated:YES];
    });
}
我知道这是一个很大的要求,但我已经在这几天了。 所有与视图无关的代码,即MFMailViewComposer工作正常,我已经在其他应用程序中对其进行了测试

我尝试了各种各样的变化来推动新的模态视图,即。
self.parentViewController.navigationController呈现模式…
(等)


什么也没用=/

我像两天前一样有同样的问题

试试这个

当您按下“detailViewController”上的按钮时,您试图以模式显示MFMailComposeViewController,对吗

因此,它引发异常的一个原因是,一旦您以模态方式显示MFMailComposeViewController,您就会释放“detailViewController”。因此,MFMailComposeViewController无法返回到“detailViewController”


检查您是否在“detailViewController”上使用了autorelease,或者在“detailViewController”的析构函数中放置了断点并对其进行调试。

结果表明这是iOS5中的一个错误。在一个单独的项目上重新创建代码后,它成功了。因此,我将问题追溯到iOS5外观定制协议,当我尝试在UINavigationBar中更改字体时,它会在MFMailComposeViewController和iOS6中的另一个模式视图中导致错误

我已经向苹果公司提交了一份雷达文件