2012-12-18 79 views
1

我從Julius Oklamcak複製了一些很好的pdf查看代碼。 https://github.com/vfr/Viewer 當我不修改它時,它在他的應用程序中效果很好,但是當我將它放入我自己的應用程序時,它會變得混亂。 我刪除了打印,書籤和平鋪視圖按鈕fyi。NSInternalInconsistencyException PDF查看器

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 
} 

我真的很感激一些幫助,這傢伙。謝謝!

回答

2

我遇到了使用此PDF查看代碼的相同問題。我只是添加了這個方法

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

到我打電話從- (IBAction)didClickOpen .m文件。 這主要是由於在ReaderViewController.m中,委託人希望看到在實現文件中聲明的dismissReaderViewController。否則,它會拋出你遇到的錯誤。

注意:使用[self dismissViewControllerAnimated:YES completion:nil];爲iOS6的或更高版本,因爲dismissModalViewControllerAnimated:被廢棄YES :-)

+0

YESSS!非常感謝你的幫助。現在工作很好。 – bowtieguy