“应用程序尝试以模态方式呈现活动控制器”iOS5中的错误 [英] “Application tried to present modally an active controller” Error in iOS5

查看:116
本文介绍了“应用程序尝试以模态方式呈现活动控制器”iOS5中的错误的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个错误导致我的应用程序仅在iPad上的iOS5下崩溃。

I have an error which is causing my app to crash under iOS5 only on the iPad.

当用户点击某个项目时,会调用以下代码uibarbutton项目:

The below code is called when the user taps on an item in a uibarbutton item :

- (void)optionSelected:(NSString *)option {

[self.optionPickerPopover dismissPopoverAnimated:YES];

if ([option compare:@"Map View"] == NSOrderedSame) {
    NSLog(@"Map View"); 
    MapView * map = [[MapView alloc] initWithNibName:@"MapView" bundle:nil]; 

    UINavigationController *navigationController = [[UINavigationController alloc] initWithRootViewController:map];

    UIBarButtonItem *rightButton = [[UIBarButtonItem alloc] initWithTitle:@"Done"
                                                                    style:UIBarButtonItemStyleDone target:self action:@selector(removeCurrent)];
    map.navigationItem.rightBarButtonItem = rightButton;

    [self presentModalViewController:navigationController animated:YES];

    [navigationController release];
    [map release];     
    [rightButton release];
    [split presentModalViewController:map animated:YES];
}

有谁能说明为什么会出现在iOS5中?

Can anyone suggest why this occurring in iOS5 ?

推荐答案

您收到此错误是因为您试图两次显示地图视图控制器。第一次是'navigationController'的根视图控制器,第二次是通过 [split presentModalViewController:map animated:YES]

You are getting this error because you are attempting to display the 'map' view controller twice. The first time is as the root view controller of 'navigationController' and the second time is via [split presentModalViewController:map animated:YES].

当您尝试使用视图控制器进行奇怪的操作时,iOS 5比iOS 4更挑剔。试图两次显示相同的控制器是一个设计问题 - 你需要找出你真正想做的事情并修复它。

iOS 5 is being a bit more picky than iOS 4 when you try to do strange things with view controllers. Trying to show the same controller twice is a design problem - you need to work out what you are really trying to do and fix it.

(另外,调用地图视图控制器'MapView'而不是'MapViewController'实在令人困惑)

(Also, calling a map view controller 'MapView' rather than 'MapViewController' is really confusing)

这篇关于“应用程序尝试以模态方式呈现活动控制器”iOS5中的错误的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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