2012-07-02 2 views
2

Th 문제는 "success"가 항상 false를 반환한다는 것입니다. 나는 문제가 무엇이 아닌가?UIDocumentInteractionController는 Ibook에서 문서를 열지 못합니다.

내 코드를 다음과 같이

UIDocumentInteractionController *docController = [[UIDocumentInteractionController interactionControllerWithURL:currentPDFPath] retain]; 

if (docController) 
{ 
    docController.delegate = self; 

    BOOL success = [docController presentOptionsMenuFromBarButtonItem:openInButton animated:YES]; 
    //BOOL success = [docController presentOpenInMenuFromBarButtonItem:openInButton animated:YES]; 
    NSLog(@"success: %d", success); 
    if(!success) 
    { 
     UIAlertView * noApps = [[UIAlertView alloc] initWithTitle:@"Error" message:@"Your iPad doesn't seem to have any other Apps installed that can open this document (such as iBooks)" delegate:nil cancelButtonTitle:@"OK" otherButtonTitles:nil]; 

     [noApps show]; 
     [noApps release]; 

    } 
} 
    [docController release]; 
+0

currentPDFPath에는 무엇이 들어 있습니까? –

+1

파일 : //localhost/var/mobile/Applications/14DD059B-9969-4960-8E24-DC586A4302D1/Library/Caches/http-__wgsn.howoco.com_media_event_117_AW12_13_Tradeshow_seasonal_analysis_-_colour_1340296472.pdf%3F1340297029 –

+0

@PriyankaChhetri는 u는 이것에 대한 해결책을 찾았나요 , 알려 주시기 바랍니다, 감사합니다 :) –

답변

0

class reference documentation는 말한다 :

반환 값

옵션 메뉴가 표시 한 경우 YES 또는 NO가 아니었다면. 메뉴에 포함 할 적절한 항목이없는 경우 옵션 메뉴가 표시되지 않을 수 있습니다.

나는 currentPDFPath에 당신의 %3F1340297029 접미사가 UTI 일치를 방지 할 수있다 생각합니다.

속성이 docController인지 확인하고 nil 인 경우 kUTTypePDF으로 설정하십시오.

+0

답장을 보내 주셔서 감사합니다.이 문제는 해결되었습니다. 이제 "BOOL success"가 1을 반환합니다.하지만이 PDF는 iBook에서 열 수 없습니다. –

+0

이제 오류는 "*** 캐치되지 않은 예외 'NSGenericException'으로 인해 응용 프로그램을 종료합니다. 이유는 : 'popover가 여전히 표시되는 동안 [UIPopoverController dealloc]에 도달했습니다.' –

0

내가하지 당신이 당신의 비 ARC 코드에 맞게 변경해야합니다, 그래서 내가, ARC를 사용하고, 나를 위해 노력하고, 코드 약간 수정했습니다. 라인이 FALSE 경우

BOOL success = [self.documentInteractionController presentOpenInMenuFromRect:rect inView:self.view animated:YES]; 

       if (success == NO) { 
        NSLog(@"No application was found"); 
       } else { 

        NSLog(@"Applications were found"); 
       } 

BOOL 중 하나 YES 또는 NO, YES를 반환하는 것은 그것 = 뒤에 선은 TRUENO입니다.

--David

관련 문제