我正在使用这个名为 Vfr Reader 的开源控件在我的应用程序中显示 pdf 文件。一切都在 iOS 7 上运行。当我尝试打开 pdf 文件时,iOS 更新应用程序崩溃后。
我正在使用此代码来初始化 pdf 阅读器。
NSString *fileName = [[NSBundle mainBundle] pathForResource:@"PdfName" ofType:@"pdf"];
ReaderDocument *document = [ReaderDocument withDocumentFilePath:fileName password:nil];
if (document != nil)
{
ReaderViewController *readerViewController = [[ReaderViewController alloc] initWithReaderDocument:document];
readerViewController.delegate = self;
readerViewController.modalTransitionStyle = UIModalTransitionStyleCrossDissolve;
readerViewController.modalPresentationStyle = UIModalPresentationFullScreen;
[self presentViewController:readerViewController animated:YES completion:Nil];
}
应用程序在 vfr 的此功能中崩溃
+ (NSString *)relativeFilePath:(NSString *)fullFilePath
{
assert(fullFilePath != nil); // Ensure that the full file path is not nil
NSString *applicationPath = [ReaderDocument applicationPath]; // Get the application path
NSRange range = [fullFilePath rangeOfString:applicationPath]; // Look for the application path
assert(range.location != NSNotFound); // **Crashes here**
return [fullFilePath stringByReplacingCharactersInRange:range withString:@""]; // Strip it out
}
在崩溃调试器上显示这些值。
fullFilePath = @"/Users/GuruTraxiOSDev01/Library/Developer/CoreSimulator/Devices/CC9412A6-9A95-4F46-89BA-8ECC13D0AF19/data/Containers/Bundle/Application/D2DC440B-F010-4575-93FD-3CB05BFF4F78/AppName.app/PdfName .pdf" 0x798c9b30
范围=位置=2147483647,长度=0
applicationPath =@"/Users/GuruTraxiOSDev01/Library/Developer/CoreSimulator/Devices/CC9412A6-9A95-4F46-89BA-8ECC13D0AF19/data/Containers/Data/Application/32D612DE-FFD2-4C1E-B403-CDA177B460A6" 0x798b46b0
我已经确认了文件的存在。任何人都可以帮忙吗!
编辑:这个问题解决了文件加载崩溃。但是应用程序仍然在 CGContextDrawPDFPage(context, thePDFPageRef);