2012-11-02 2 views
1

나는 vfr/reader을 사용하여 PDF 파일을 열 것입니다. 첫 번째 PDF 파일을 열면 내 앱이 올바르게 열리지 만 다른 파일을 열면 내 앱에서 첫 번째 파일을 다시 엽니 다. VFR Reader가있는 Xcode 다운로드 PDF 실수

는 PDF 파일을

-(void)readIssue:(IssueMath *)issue { 

    NSString *filePath = [[issue.contentURL path] stringByAppendingPathComponent:@"Mathematics.pdf"]; 

    NSLog(@"Read Path 1: %@ ",filePath); 

    ReaderDocument *document = [ReaderDocument withDocumentFilePath:filePath password:nil]; 
    NSLog(@"Read Path 2: %@ ",document.fileURL); 

    ReaderViewController *readerViewController = [[ReaderViewController alloc] initWithReaderDocument:document]; 
    readerViewController.delegate = self; // Set the ReaderViewController delegate to self 

    readerViewController.modalTransitionStyle = UIModalTransitionStyleCrossDissolve; 
    readerViewController.modalPresentationStyle = UIModalPresentationFullScreen; 

    [self presentModalViewController:readerViewController animated:YES]; 
} 

를 읽어 내 기능입니다 그리고 이것은 NSLog 출력 :

나는 "ISSUE3_2011/Mathematics.pdf"을 읽고 싶어하지만 응용 프로그램은 여전히 ​​첫 번째 경로 "를 읽고
2012-11-02 20:09:31.081 MAGAZINE[314:15203] Read Path 1: /Users/eakmotion/Library/Application Support/iPhone Simulator/5.0/Applications/EC25BC08-E1E7-44B6-9AD8-0A321EEAC8B6/Library/Caches/ISSUE3_2011/Mathematics.pdf 

2012-11-02 20:09:31.109 MAGAZINE[314:15203] Read Path 2: file://localhost/Users/eakmotion/Library/Application%20Support/iPhone%20Simulator/5.0/Applications/EC25BC08-E1E7-44B6-9AD8-0A321EEAC8B6/Library/Caches/ISSUE2_2011/Mathematics.pdf 

ISSUE2_2011/Mathematics.pdf "

filePath이 여전히 동일한가요?

이 문제를 어떻게 해결할 수 있습니까?

답변

3

그래 솔루션은 작동하지만 당신은 당신의 모든 PDF 문서를 추적 할 (더 예. 현재 페이지) 당신이 수학을 검색합니다 때문에 .. 해당 지역의 PDF 파일에 대해 고유 한 이름을 지정해야

을하지 않으 .plist 파일을 로컬 장치 폴더에 저장하면 현재 페이지 번호를 읽을 수 있습니다 ..

사용자/eakmotion/라이브러리/응용 프로그램 지원/iPhone 시뮬레이터/5.0/응용 프로그램/EC25BC08-E1E7-44B6-9AD8-0A321EEAC8B6/라이브러리/캐시/ISSUE3_2011/Mathematics.pdf

file : //localhost/Users/eakmotion/Library/Application%20Support/iPhone%20Simulator/5.0/Applicat 이온/EC25BC08-E1E7-44B6-9AD8-0A321EEAC8B6/도서관/캐시/ISSUE2_2011/Mathematics.pdf이 파일은 클래스 ReaderDocument에서 같은 Mathematics.plist 파일 를 찾고 있습니다

"unarchiveFromFileName"방법

NSString *archivePath = [ReaderDocument applicationSupportPath]; // Application's "~/Library/Application Support" path 

NSString *archiveName = [[filename stringByDeletingPathExtension] stringByAppendingPathExtension:@"plist"]; 

이 코드 섹션을 수정하거나 파일을 Mathematics_ISSUE3_2011.pdf 및 Mathematics_ISSUE2_2011.pdf 같은 고유 한 이름을 부여하려고

+0

2 개의 pdfs가 magazine.pdf라고해도이 문제는 발견되지 않습니다. 2 개의 pdfs는 다른 폴더에 있습니다. – Mickey

+1

예 2 pdfs는 다른 폴더에 있지만 마지막으로 열린 PDF 파일과 Documents/Mathematics.plist에 저장된 페이지 번호 정보를 저장하는 파일이 있습니다.이 PDF 파일의/Library/Caches/plist 파일에도 pdf 파일이 있습니다 똑같을거야. –

2

나는이 질문이 꽤 몇 개월 전인 것을 알고있다. 그러나 누군가 내 자신과 같은 문제를 겪고있는 경우에 대비해 해결책을 찾았다.

vfr/reader의 소스에서 Sources/ReaderDocument.m 파일을 찾고 + (ReaderDocument *)withDocumentFilePath:이라는 함수를 찾으십시오.

아래에 표시된대로 문서를 다시로드하지 못하게하는 조건을 주석으로 작성하십시오.

+ (ReaderDocument *)withDocumentFilePath:(NSString *)filePath password:(NSString *)phrase 
{ 
    ReaderDocument *document = nil; // ReaderDocument object 

    document = [ReaderDocument unarchiveFromFileName:filePath password:phrase]; 

    //if (document == nil) // Unarchive failed so we create a new ReaderDocument object 
    //{ 
    document = [[ReaderDocument alloc] initWithFilePath:filePath password:phrase]; 
    //} 

    return document; 
} 

문서를 다시로드하는 것이 빠르고 쉽습니다. 이 솔루션에 대한주의 사항은 pdf 리더가 내 앱에서 중요한 부분이 아닌 pdf 페이지에서 중단 한 부분을 추적하지 않는다는 것입니다.

+0

왜 'document = [ReaderDocument unarchiveFromFileName : filePath password : phrase];'에 댓글을 작성하지 않으셨습니까? – Dmitry

1
저도 같은 문제에 직면했다

발견 다음과 같은 솔루션 :

// Path to first PDF file 
NSString *filePath = 
    [[NSBundle mainBundle] pathForResource:@"someBookeName" ofType:@"pdf"]; 

위와 같이 파일 경로를 변경하십시오. 보시다시피 이제 NSArray * PDF이 필요하지 않습니다.