现已升级到dimissModalViewcontroller上的xcode 4.2现在exc_bad_access [英] upgraded to xcode 4.2 now exc_bad_access on dimissModalViewcontroller

查看:102
本文介绍了现已升级到dimissModalViewcontroller上的xcode 4.2现在exc_bad_access的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个奇怪的问题.

我的应用基于"PageControl"的示例代码(Apple示例). 它使用水平滚动视图,其中发生了大多数事情. 在他的底部,我有一个UIToolbar,从中可以调用模式视图控制器.

My app is based on the samplecode of "PageControl" (the Apple example). It uses a horizontal scrollview in which most of the stuff is happening. At he bottom I have a UIToolbar from which I call a modal viewcontroller.

在XCode 4上,一切都像魅力一样,在升级到XCode 4.2(使用新的SDK)之后,我在dimissModalViewcontroller上获得了"exc_bad_access". 最有趣的是,它不会立即发生,只有在出现和关闭modalViewcontroller两次或三遍之后才会发生.

On XCode 4 everything worked like a charm, after the upgrade to XCode 4.2 (with the new SDK) I get a "exc_bad_access" on dimissModalViewcontroller. The funniest thing is that it does not happen rightaway but only after 2 or 3 times presenting and dismissing the modalViewcontroller.

为简化起见,我回到了原始的示例代码,并尝试在该上下文中实现modalVieWcontroler.到目前为止没有运气.

To simplify things I went back to the original samplecode and tried to implement the modalVieWcontroler in that context. No luck so far.

在原始的PageControl代码中,我将"ContentController"的类型从NSObject更改为UIViewController,如下所示:

In the original PageControl Code I changed the type of "ContentController" from NSObject to UIViewController like so:

@interface ContentController : UIViewController
{
    NSArray *contentList;
}

我在一个名为PhoneContentController的子类(来自ContentController)中调用presentModalViewcontroller,如下所示:(我使用了一个通知,因此可以在任何地方调用它)

I call presentModalViewcontroller in a sub class (from ContentController) named PhoneContentController like so:(I use a notification so I can call it from anywhere)

-(void) showExplanationsModal:(NSNotification*)notification{

    ExplanationsViewController *xplViewController = [[[ExplanationsViewController alloc] initWithNibName:@"Explanations" bundle:nil]autorelease];

    [self presentModalViewController:xplViewController animated:YES];
}

从模态视图本身调用modalViewcontroller的解雇,如下所示: (该通知用于启动其他内容)

The dismissal of the modalViewcontroller is called from the modal view itself like so: (the notification is used tot initiate some other stuff)

 - (IBAction)onClose
{
    [self dismissModalViewControllerAnimated:YES];

    [[NSNotificationCenter defaultCenter]postNotificationName:@"dismissExplanationsModal" object:self];

}

此代码在iOS4 SDK上正常工作,但在iOS5 SDK上偶尔会出现excec_bad_access. 当我使用iOS4 SDK编译应用程序时,在iOS5设备上也可以正常运行. 我尝试使用僵尸",但这并不指向特定的过度释放对象. 我已经呆了几天了...

This code works fine with iOS4 SDK but renders occasional excec_bad_access with iOS5 SDK. When I compile the app with iOS4 SDK it also rus fine on iOS5 devices. I tried using Zombies but this does not point to a specific over-released object. I'm sort of stuck on this one for a few days already ...

我已经提供了一个示例项目的副本,用于在此处说明问题. http://www.sesni .biz/pagecontrol.zip

I have put up a copy of a sample project that illustrates the problem here http://www.sesni.biz/pagecontrol.zip

推荐答案

发现了问题:我将ContententController的类型从NSObject更改为UIViewcontroller.这可以在iOS4 SDK上正常运行,但在iOS5 SDK上崩溃.

Found the problem: I changed the type of ContententController from NSObject to UIViewcontroller. This worked fine with the iOS4 SDK but crashes with iOS5 SDK.

这篇关于现已升级到dimissModalViewcontroller上的xcode 4.2现在exc_bad_access的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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