0

我编写代码来打开位于的 pdf 文件

  NSArray  *paths =    NSSearchPathForDirectoriesInDomains(NSDocumentDirectory , NSUserDomainMask, YES);
        NSString *documentsDir = [paths objectAtIndex:0];
        NSString *pdfFilePath =[documentsDir  stringByAppendingPathComponent:@"421_core_animation_essentials.pdf"];
        fileURL = [NSURL URLWithString:pdfFilePath];
        QLPreviewController *previewController = [[QLPreviewController alloc] init];
        previewController.dataSource = self;
        [[self navigationController] pushViewController:previewController animated:YES];
        [previewController.navigationItem setRightBarButtonItem:nil];
        [previewController release];

它在模拟器中测试时工作,但在 iPad 设备中测试时它不起作用。请帮我。

4

1 回答 1

0

iOS 设备文件系统区分大小写,而模拟器则不区分大小写。

因此检查文件名是否区分大小写:

NSString *pdfFilePath =[documentsDir  stringByAppendingPathComponent:@"421_core_animation_essentials.pdf"];
于 2012-08-09T11:38:44.070 回答