【问题标题】:NSInternalInconsistencyException PDF ViewerNSInternalInconsistencyException PDF 查看器
【发布时间】:2013-01-14 06:24:15
【问题描述】:

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

完成按钮不起作用。

这是我收到的错误:

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
}

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

【问题讨论】:

    标签: pdf viewer


    【解决方案1】:

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

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

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

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

    【讨论】:

    • 是的!非常感谢你的帮助。现在工作得很好。
    猜你喜欢
    • 1970-01-01
    • 2012-12-13
    • 2011-05-25
    • 2011-10-16
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2022-01-22
    • 1970-01-01
    相关资源
    最近更新 更多