2012-01-28 57 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中导航不同的页面...