调用'presentViewController'时EXC_BAD_ACCESS(代码2)

时间:2014-04-05 20:32:37

标签: ios objective-c cocoa-touch uiviewcontroller nszombie

我真的很难过。

_vc = [[VLCKitViewControlleriPhone alloc]initWithNibName:@"VLCKitViewControlleriPhone" bundle:nil];
_vc.modalPresentationStyle = UIModalPresentationFullScreen;
[self presentViewController:_vc animated:YES completion:nil];

调用presentViewController方法时,给我EXC_BAD_ACCESS(code = 2,address = 0x0)。视图控制器不是零。它也有或没有笔尖名称。如果我注释掉presentViewController行,其余的代码继续正常,包括对视图控制器本身进行的方法调用。视图控制器正在运行,我只是看不到任何东西,因为它实际上没有显示视图。

我启用了NSZombies,并在仪器运行的情况下尝试了它,但它没有向我显示任何内容。该应用程序退出,仪器停止,而不给我任何信息。任何人都知道问题可能是什么?

1 个答案:

答案 0 :(得分:0)

你可以试试这个

if ([controller respondsToSelector:@selector(setModalPresentationStyle:)])
{
    [controller setModalPresentationStyle:UIModalPresentationFullScreen];
} else {
    [controller setModalPresentationStyle:UIModalPresentationFormSheet];
}