Objective c 从NSURL-SIGABIT错误在VFR读取器上加载PDF
我在iPad存储器上有一个带有pdf文件地址的URL:Objective c 从NSURL-SIGABIT错误在VFR读取器上加载PDF,objective-c,pdf,Objective C,Pdf,我在iPad存储器上有一个带有pdf文件地址的URL: /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 *)iss
/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"];
在这段代码上面,我有de VFR阅读器代码,可以从这个URL加载这个文件。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]));
}
}
我看不出这里发生了什么。在谷歌上搜索时,我看到了这个错误。SIGABRT似乎是来自xcode的错误
我已经做了好几个小时了,如果有人在VFR阅读器方面有更多的经验,我很感激他能最好地指导我解决这个错误。试试这个
NSString *filePath = [urlOfReadingIssue path];
而不仅仅是
NSString *filePath = urlOfReadingIssue;
直接将NSUrl分配给NSString可能会导致此问题
请参阅尝试此操作,将此代码放在同一文件中:
- (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
}
试试这个:
- (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中浏览不同的页面…请注意,您提出了12个问题,但没有接受任何答案。这可能会让人们不敢回答你的问题。你确定这是SIGABIT,不是SIGABRT吗?对不起,真的是SIGABRT。我编辑了这个问题。