从 NSURL 在 VFR 阅读器上加载 PDF - SIGABIT 错误

发布于 2024-12-29 13:00:17 字数 3469 浏览 2 评论 0 原文

我有一个 URL,其中包含 iPad 存储上我的 pdf 文件的地址:

/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 加载该文件。 Reader Demo 的原始代码是:

    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
    }

但是当我构建时,我在 @autoreleasepool 上的 AppDelegate.m 中收到线程错误“SIGABIT”:

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

我看不到这里发生了什么。在谷歌上搜索,我读到了这个错误。 “SIGABRT”似乎是来自 xcode 的错误。

我花了几个小时,如果在 VFR-Reader 方面有更多经验的人能够最好地指导我解决这个错误,我将不胜感激。

I have an URL with address of my pdf file on iPad Storage:

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

Then I have the function to which put this address in a NSURL:

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

above this code, I have de VFR-Reader code to load this file from this URL. The original code from Reader Demo is:

    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
}

My Final Code is:

-(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
    }

But when I build, I get a Thread error "SIGABIT" in AppDelegate.m on @autoreleasepool:

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

I can't see what's happening here. Searching on Google, I read about this error. "SIGABRT" seems to be an error from xcode.

I'm at it for hours, I appreciate if someone with more experience in VFR-Reader could best guide me about this error.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(3

离鸿 2025-01-05 13:00:17

尝试这个

NSString *filePath = [urlOfReadingIssue path];

而不是

 NSString *filePath = urlOfReadingIssue;

直接将 NSUrl 分配给 NSString 可能会导致此问题。

请参阅 http://developer.apple.com/library/mac/documentation/Cocoa/Reference/Foundation/Classes/NSURL_Class/Reference/Reference.html#//apple_ref/occ/instm/NSURL/path< /a>

try this

NSString *filePath = [urlOfReadingIssue path];

instead of just

 NSString *filePath = urlOfReadingIssue;

Directly assigning a NSUrl to NSString may result in this problem.

Refer to http://developer.apple.com/library/mac/documentation/Cocoa/Reference/Foundation/Classes/NSURL_Class/Reference/Reference.html#//apple_ref/occ/instm/NSURL/path

挽清梦 2025-01-05 13:00:17

试试这个:

         - (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 中的不同页面......

try this:

         - (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];     
         }

        }

i think this works fine.
Am also struggling for navigate different pages in pdf when user clicks the button...

℡Ms空城旧梦 2025-01-05 13:00:17

尝试一下,将此代码放在同一个文件中:

- (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
}

Try this, put this code in the same file:

- (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
}
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文