1

我从 Julius Oklamcak 复制了一些不错的 pdf 查看代码。https://github.com/vfr/Viewer 当我不修改它时,它在他的应用程序中效果很好,但是当我将它放在我自己的应用程序中时它会变得一团糟。我删除了打印、书签和平铺视图按钮,仅供参考。

DONE 按钮不起作用。

这是我收到的错误:

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

这是代码:

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

我真的很感谢这些家伙的帮助。谢谢!

4

1 回答 1

1

我使用此 PDF 查看代码遇到了同样的问题。我只是添加了这个方法

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

到我调用- (IBAction)didClickOpenfrom 的 .m 文件。这主要是因为在 ReaderViewController.m 中,委托希望看到您的实现文件中声明的dismissReaderViewController。否则,它会抛出你得到的错误。

注意:[self dismissViewControllerAnimated:YES completion:nil];用于 iOS6 或更高版本,因为不推荐使用 dismissModalViewControllerAnimated:YES :-)

于 2013-01-13T22:24:15.733 回答