Загрузка PDF в VFR Reader из NSURL - ошибка SIGABIT - PullRequest
0 голосов
/ 29 января 2012

У меня есть URL с andress моего pdf файла на iPad Storage:

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

Затем у меня есть функция, которая помещает этот andress в NSURL:

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

вышеэтот код, у меня есть код де 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
    }

Но при сборке я получаю сообщение об ошибке "SIGABIT" в AppDelegate.m на @autoreleasepool:

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

Я не вижу, что здесь происходит.Ища в гугле, я прочитал об этой ошибке.«SIGABRT», похоже, является ошибкой из xcode.

Я занимаюсь этим часами, я ценю, если кто-то с большим опытом работы с VFR-Reader сможет лучше всего подсказать мне об этой ошибке.

Ответы [ 3 ]

0 голосов
/ 07 июня 2012

Попробуйте, поместите этот код в тот же файл:

- (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 голосов
/ 27 июля 2012

попробуйте это:

         - (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, когда пользователь нажимает кнопку ...

0 голосов
/ 01 февраля 2012

попробуйте

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

Добро пожаловать на сайт PullRequest, где вы можете задавать вопросы и получать ответы от других членов сообщества.
...