我在iPad存储上有一个带有我的pdf文件地址的网址:
/Library/Application%20Support/iPhone%20Simulator/5.0/Applications/78AB0683-5B3F-4AD6-83BB-236D9623574B/Library/Caches/Newsstand/953C71E3-CED3-4369-993F-9132119269EC/然后我有一个函数,它把这个地址放在一个NSURL中:
-(void)readIssue:(Issue *)issue {
urlOfReadingIssue=[[issue contentURL] URLByAppendingPathComponent:@"magazine.pdf"];在这段代码之上,我有从这个URL加载这个文件的de VFR-Reader代码。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
}但是当我构建时,我在@autoreleasepool上的AppDelegate.m中得到了一个线程错误"SIGABIT“:
int main(int argc, char *argv[])
{
@autoreleasepool {
return UIApplicationMain(argc, argv, nil, NSStringFromClass([AppDelegate class]));
}
}我看不出这是怎么回事。在Google上搜索,我读到了这个错误。"SIGABRT“似乎是来自xcode的错误。
我已经做了几个小时了,如果有更多VFR阅读器经验的人能最好地指导我解决这个错误,我会很感激。
发布于 2012-02-01 17:55:59
尝尝这个
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
发布于 2012-06-08 00:07:44
试试这个,把下面的代码放在同一个文件中:
- (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
}发布于 2012-07-27 13:30:34
试试这个:
- (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中导航不同的页面…
https://stackoverflow.com/questions/9048406
复制相似问题