UIDocumentInteractionController在退出时崩溃
|
我的主菜单上有一个常规的UIButton,当前会启动一个UIViewController。相应的.m文件的内容如下:
-(id)initWithNibName:(NSString *)nibNameOrNil bundle:(NSBundle *)nibBundleOrNil
{
self = [super initWithNibName:nibNameOrNil bundle:nibBundleOrNil];
documentPath = [[NSBundle mainBundle] pathForResource:@\"file\" ofType:@\"pdf\"];
NSURL *targetURL = [NSURL fileURLWithPath:documentPath];
document = [UIDocumentInteractionController interactionControllerWithURL: targetURL];
document.delegate = self;
[document retain];
return self;
}
-(UIViewController *)documentInteractionControllerViewControllerForPreview: (UIDocumentInteractionController *) controller
{
return self;
}
-(void)documentInteractionControllerDidEndPreview:(UIDocumentInteractionController *)controller
{
[document autorelease];
}
-(void)viewDidLoad
{
[super viewDidLoad];
[document presentPreviewAnimated: YES]; // ** CRASH **
}
-(void)viewDidUnload
{
[super viewDidUnload];
}
-(void)didReceiveMemoryWarning
{
[super didReceiveMemoryWarning];
}
-(BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation
{
return YES;
}
-(void)dealloc
{
[super dealloc];
}
我的pdf文件按预期加载,但是,当我按“完成”按钮时,文档关闭,而我盯着空白的UIViewController-可以说是预期的。但是,如果我按下导航“后退”按钮,则该应用程序崩溃,并且在viewDidLoad方法内部出现严重的访问错误,在该方法中找到了对presentPreviewAnimated的调用。
如果有人可以请看,我将不胜感激。
(顺便说一句,创建此视图控制器时没有NIB文件。是的,这本身是错误的)
没有找到相关结果
已邀请:
1 个回复
缔恃钨