从 NSURL 在 VFR 阅读器上加载 PDF - SIGABIT 错误
我有一个 URL,其中包含 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"];
在此代码之上,我有 de VFR-Reader 代码从该 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-Reader 方面有更多经验的人能够最好地指导我解决这个错误,我将不胜感激。
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
尝试这个
而不是
直接将
NSUrl
分配给NSString
可能会导致此问题。请参阅 http://developer.apple.com/library/mac/documentation/Cocoa/Reference/Foundation/Classes/NSURL_Class/Reference/Reference.html#//apple_ref/occ/instm/NSURL/path< /a>
try this
instead of just
Directly assigning a
NSUrl
toNSString
may result in this problem.Refer to http://developer.apple.com/library/mac/documentation/Cocoa/Reference/Foundation/Classes/NSURL_Class/Reference/Reference.html#//apple_ref/occ/instm/NSURL/path
试试这个:
我认为这很好用。
当用户单击按钮时,我也在努力导航 pdf 中的不同页面......
try this:
i think this works fine.
Am also struggling for navigate different pages in pdf when user clicks the button...
尝试一下,将此代码放在同一个文件中:
Try this, put this code in the same file: