2016-03-06 65 views
1

我有應用程序生成報告爲PDF文件。 我可以生成PDF文件,但我收到一個警告:「無法找到代理的預覽項目: - CalculationSheet.pdf(0)」迅速警告:找不到代理的預覽項目

任何意見,爲什麼我收到此錯誤? 哪個斷點我可以放在爲了跟隨這個錯誤的原因。

回答

1
// returns the item that the preview controller should preview 

-(id)previewController:(QLPreviewController *)previewController previewItemAtIndex:(NSInteger)idx 
{ 
    NSURL *fileURL = nil; 

    NSIndexPath *selectedIndexPath = [self.tableView indexPathForSelectedRow]; 
    if (selectedIndexPath.section == 0) 
    { 
     fileURL = [NSURL fileURLWithPath:[[NSBundle mainBundle] pathForResource:documents[idx] ofType:nil]]; 
    } 
    else 
    { 
     fileURL = [self.documentURLs objectAtIndex:idx]; 
    } 

    return fileURL; 
} 
+2

除了發佈代碼片段之外,建議您也將其放到問題的上下文中並解釋問題的解決方案,以便OP可以從中學習。請閱讀如何編寫[良好的答案](http://stackoverflow.com/help/how-to-answer)並對其進行改進。 – user3078414

+0

代碼在目標c中,我應該在哪裏插入此代碼,因爲我的代碼是用swift編寫的。 –