2012-01-28 61 views
0

我有一個網址上的iPad存儲我的PDF文件的安德斯:加載PDF從NSURL - SIGABIT錯誤

/Library/Application%20Support/iPhone%20Simulator/5.0/Applications/78AB0683-5B3F-4AD6-83BB-236D9623574B/Library/Caches/Newsstand/953C71E3-CED3-4369-993F-9132119269EC/ 

然後我不得不至極把這個安德絲在NSURL功能:

-(void)readIssue:(Issue *)issue { 
    urlOfReadingIssue=[[issue contentURL] URLByAppendingPathComponent:@"magazine.pdf"]; 

上面這段代碼,我有de VFR-Reader代碼來從這個URL加載這個文件。從讀者演示原代碼是:

NSString *phrase = nil; // Document password (for unlocking most encrypted PDF files) 

NSArray *pdfs = [[NSBundle mainBundle] pathsForResourcesOfType:@"pdf" inDirectory:nil]; 

NSString *filePath = [pdfs lastObject]; assert(filePath != nil); // Path to last PDF file 

ReaderDocument *document = [ReaderDocument withDocumentFilePath:filePath password:phrase]; 

if (document != nil) // Must have a valid ReaderDocument object in order to proceed with things 
{ 
    ReaderViewController *readerViewController = [[ReaderViewController alloc] initWithReaderDocument:document]; 

    readerViewController.delegate = self; // Set the ReaderViewController delegate to self 

    if (DEMO_VIEW_CONTROLLER_PUSH == TRUE) 

    [self.navigationController pushViewController:readerViewController animated:YES]; 

#else // present in a modal view controller 

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

    [self presentModalViewController:readerViewController animated:YES]; 

    #endif // DEMO_VIEW_CONTROLLER_PUSH 

    [readerViewController release]; // Release the ReaderViewController 
} 

我最後的代碼是:

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

urlOfReadingIssue=[[issue contentURL] URLByAppendingPathComponent:@"magazine.pdf"]; 


NSString *phrase = nil; // Document password (for unlocking most encrypted PDF files) 

    NSString *filePath = urlOfReadingIssue; 

    ReaderDocument *document = [ReaderDocument withDocumentFilePath:filePath 
                  password:phrase]; 

    if (document != nil) // Must have a valid ReaderDocument object in order to proceed with things 
    { 
     ReaderViewController *readerViewController = [[ReaderViewController alloc] initWithReaderDocument:document]; 

     readerViewController.delegate = self; // Set the ReaderViewController delegate to self 

#if (DEMO_VIEW_CONTROLLER_PUSH == TRUE) 

     [self.navigationController pushViewController:readerViewController animated:YES]; 

#else // present in a modal view controller 

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

     [self presentModalViewController:readerViewController animated:YES]; 

#endif // DEMO_VIEW_CONTROLLER_PUSH 

     [readerViewController release]; // Release the ReaderViewController 
    } 

但是,當我建,我在AppDelegate.m獲得一個線程錯誤 「SIGABIT」 上@autoreleasepool:

int main(int argc, char *argv[]) 
{ 
    @autoreleasepool { 
     return UIApplicationMain(argc, argv, nil, NSStringFromClass([AppDelegate class])); 
    } 
} 

我不能看到這裏發生了什麼。在谷歌上搜索,我讀了關於這個錯誤。 「SIGABRT」似乎是來自xcode的錯誤。

我在這裏待了好幾個小時,我很感謝有更多VFR-Reader經驗的人能夠最好地指導我這個錯誤。

+2

請注意,您提出了12個問題,並且不接受任何答案。這可能會迴避人們回答你的問題。 – Bobrovsky 2012-01-28 21:00:47

+0

你確定它是SIGABIT,而不是SIGABRT? – 2012-01-28 21:33:16

+0

對不起,它真的是SIGABRT。我編輯了這個問題。 – 2012-01-29 12:54:47

回答

0

試試這個,把這個代碼在同一個文件:

- (void)dismissReaderViewController:(ReaderViewController *)viewController 
{ 
#ifdef DEBUGX 
    NSLog(@"%s", __FUNCTION__); 
#endif 

#if (DEMO_VIEW_CONTROLLER_PUSH == TRUE) 

    [self.navigationController popViewControllerAnimated:YES]; 

#else // dismiss the modal view controller 

    [self dismissModalViewControllerAnimated:YES]; 

#endif // DEMO_VIEW_CONTROLLER_PUSH 
} 
0

試試這個:

  - (void)handleSingleTap:(UITapGestureRecognizer *)recognizer 
     { 
     [self seeYou:@"Complete Book-02"]; 
     } 

     -(void)seeYou:(NSString *)filename 
     { 
      NSString *phrase = nil; 
     NSString *file1=[[NSBundle mainBundle]pathForResource:filename ofType:@"pdf"]; 
    ReaderDocument *document = [ReaderDocument withDocumentFilePath:file1 password:phrase]; 
    if (document != nil) 
    { 
    ReaderViewController *readerViewController = [[ReaderViewController alloc] initWithReaderDocument:document]; 
    readerViewController.delegate = self; 

      #if (DEMO_VIEW_CONTROLLER_PUSH == TRUE) 

    [self.navigationController pushViewController:readerViewController animated:YES]; 

      #else 
    readerViewController.modalTransitionStyle = UIModalTransitionStyleCrossDissolve; 
    readerViewController.modalPresentationStyle = UIModalPresentationFullScreen; 
    [self presentModalViewController:readerViewController animated:YES]; 

      #endif 

    [readerViewController release];  
     } 

     } 

我覺得這工作得很好。 當用戶點擊按鈕時,我也努力在pdf中導航不同的頁面...