我在UIScrollView中顯示PDF。要做到這一點我使用:如何將NSString路徑轉換爲CFURLRef(適用於iOS 3.1)?
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"
我該如何解決這個問題?