2011-12-08 2 views

답변

0

실제로 앱에서 PDF 파일을 열어서 iBooks (또는 PDF 파일을 읽을 수있는 다른 설치된 앱)로 열 수 있습니다.

이렇게하려면, 당신은 UIDocumentInteractionController

NSString *pdfPath = @"path to your pdf file"; 
NSURL *url = [NSURL fileURLWithPath:pdfPath]; 
UIDocumentInteractionController *docController = [UIDocumentInteractionController interactionControllerWithURL:url]; 

docController.delegate = self; 
[docController retain]; 
// docController is released when dismissed (autorelease in the delegate method) 

BOOL isValid = [docController presentOpenInMenuFromRect:readPdfButton.frame inView:self.view animated:YES]; 

if (!isValid) { 
    NSString * messageString = [NSString stringWithFormat:@"No PDF reader was found on your device. In order to consult the %@, please download a PDF reader (eg. iBooks).", yourPDFFileTitle]; 

    UIAlertView * alertView = [[UIAlertView alloc] initWithTitle:@"Error" message:messageString delegate:nil cancelButtonTitle:@"OK" otherButtonTitles:nil]; 
    [alertView show]; 
    [alertView release]; 
} 

... 

// UIDocumentInteractionController delegate method 
- (void)documentInteractionControllerDidDismissOpenInMenu:(UIDocumentInteractionController *)controller { 
    [controller autorelease]; 
} 

UIDocumentInteractionController가 설치된 모든 PDF 수있는 응용 프로그램의 선택과 팝 오버 (아이 패드) 또는 (아이폰) 액션 시트를 엽니 다 사용할 수 있습니다 장치에서 사용자가 원하는 PDF 파일을 선택하여 PDF를 읽을 수 있습니다.

는 오히려 그 중 하나, 응용 프로그램을 전환 할 필요없이 앱에서 직접 PDF를 여는 데 사용할 수 있습니다 또한 몇 가지 괜찮은 PDF 리더 라이브러리가 있습니다 VFR PDF Reader/Viewer for iOS

관련 문제