我在 UIScrollView 中显示 PDF。为此,我使用:
myDocumentRef = CGPDFDocumentCreateWithURL((CFURLRef)[[NSBundle mainBundle] URLForResource:@"salonMap" withExtension:@"pdf"]);
现在,我尝试让它在 IOS 3.1 上工作(NSBundle URLForResource:withExtension 不存在于 3.1)
我把我的代码变成了:
NSString *fullPath = [[NSBundle mainBundle] pathForResource:@"salonMap" ofType:@"pdf"];
NSLog(@"%@", fullPath);
CFStringRef fullPathEscaped = CFURLCreateStringByAddingPercentEscapes(NULL,(CFStringRef)fullPath, NULL, NULL,kCFStringEncodingUTF8);
CFURLRef urlRef = CFURLCreateWithString(NULL, fullPathEscaped, NULL);
myDocumentRef = CGPDFDocumentCreateWithURL(urlRef);
但这会导致
<Error>: CFURLCreateDataAndPropertiesFromResource: failed with error code -15
我准确地说 NSLog 日志
/var/mobile/Applications/1CF69390-85C7-45DA-8981-A279464E3249/myapp.app/salonMap.pdf"
我该如何解决?