Вопрос

I copied some good pdf viewing code from Julius Oklamcak. https://github.com/vfr/Viewer It works great in his app when I do not modify it, but it gets messed up when I put it in my own app. I removed the print, bookmark, and tile view buttons fyi.

The DONE button is not working.

Here is the error I am receiving:

2012-12-18 10:01:45.857 TeacherTableView4[1147:907] *** Assertion failure in -[ReaderViewController tappedInToolbar:doneButton:], (...my path to)/TeacherTableView4/ReaderViewController.m:844
2012-12-18 10:01:45.859 TeacherTableView4[1147:907] *** Terminating app due to uncaught exception 'NSInternalInconsistencyException', reason: 'Delegate must respond to -dismissReaderViewController:'
*** First throw call stack:
(0x371b52a3 0x3bd9497f 0x371b515d 0x3a2682af 0x40967 0x3c9f1 0x3676f0a5 0x3676f057 0x3676f035 0x3676e8eb 0x3676ede1 0x366975f1 0x36684801 0x3668411b 0x34a4f5a3 0x34a4f1d3 0x3718a173 0x3718a117 0x37188f99 0x370fbebd 0x370fbd49 0x34a4e2eb 0x366d82f9 0x414bd 0x36557b20)
libc++abi.dylib: terminate called throwing an exception

Here is the code:

- (void)tappedInToolbar:(ReaderMainToolbar *)toolbar doneButton:(UIButton *)button
{
#ifdef DEBUGX
    NSLog(@"%s", __FUNCTION__);
#endif

#if (READER_STANDALONE == FALSE) // Option

[document saveReaderDocument]; // Save any ReaderDocument object changes

[[ReaderThumbQueue sharedInstance] cancelOperationsWithGUID:document.guid];

[[ReaderThumbCache sharedInstance] removeAllObjects]; // Empty the thumb cache

//COMMENTED OUT BY ME
//if (printInteraction != nil) [printInteraction dismissAnimated:NO]; // Dismiss

if ([delegate respondsToSelector:@selector(dismissReaderViewController:)] == YES)
{
    [delegate dismissReaderViewController:self]; // Dismiss the ReaderViewController
}
else // We have a "Delegate must respond to -dismissReaderViewController: error"
{
    NSAssert(NO, @"Delegate must respond to -dismissReaderViewController:");
}

#endif // end of READER_STANDALONE Option
}

I would really appreciate some help with this guys. Thanks!

Это было полезно?

Решение

I ran into the same problem using this PDF viewing code. I simply added this method

- (void)dismissReaderViewController:(ReaderViewController *) viewController 
{
[self dismissModalViewControllerAnimated:YES];
}

to the .m file where I'm calling the - (IBAction)didClickOpen from. This is mainly due to the fact that in ReaderViewController.m the delegate expects to see dismissReaderViewController declared in your implementation file. Otherwise, it will throw that error you're getting.

Note: Use [self dismissViewControllerAnimated:YES completion:nil]; for iOS6 or later since dismissModalViewControllerAnimated:YES was deprecated :-)

Лицензировано под: CC-BY-SA с атрибуция
Не связан с StackOverflow
scroll top