2012-07-02 24 views
2

問題是,「成功」總是讓我錯誤?我不是什麼問題?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沒有ü找到一個解決方案,請讓我知道,謝謝:) –

回答

0

class reference documentation說:

返回值

YES如果被顯示的選項菜單或NO,如果事實並非如此。如果菜單中沒有合適的項目,則選項菜單可能不會顯示。

我覺得你%3F1340297029後綴上currentPDFPath可能會阻止UTI比賽。

檢查UTI財產docController並設置爲kUTTypePDF如果它是nil

+0

感謝您的回覆。我的問題已解決。現在「BOOL成功」返回1.但我無法在iBook中打開此pdf。 –

+0

現在錯誤是「***終止應用程序由於未捕獲的異常'NSGenericException',原因:' - [UIPopoverController dealloc]達到彈出時仍然可見。」 –

0

我修改你的代碼了一下,不是爲我工作,我使用ARC,所以你必須改變它以適應你的非ARC代碼。

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要麼返回YESNOYES它的背後=線路TRUENO如果行是FALSE

- 大衛

相關問題