嗨,每个人我都是ios的新手
这是我的代码
NSArray *paths = NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES);
NSString *documentsDirectory = [paths objectAtIndex:0];
NSString *comicbook_id = [[NSUserDefaults standardUserDefaults]stringForKey:@"comicbook_id"];
NSString *filePath = [NSString stringWithFormat:@"%@/book_%@.pdf", documentsDirectory,comicbook_id];
documentsDirectory = [documentsDirectory stringByAppendingPathComponent:filePath];
NSLog(@"date==>%@",documentsDirectory);
***here i am getting path***
ReaderDocument *document = [ReaderDocument withDocumentFilePath:documentsDirectory password:nil];
NSLog(@"date==>%@",document);
*****here i am getting <nil>*****
if (document != nil) {
ReaderViewController *readerViewController = [[ReaderViewController alloc] initWithReaderDocument:document];
readerViewController.delegate = self;
readerViewController.view.backgroundColor = [UIColor colorWithPatternImage:[UIImage imageNamed:@"background.png"]];
readerViewController.navigationController.navigationBar.tintColor = [UIColor blackColor];
readerViewController.modalTransitionStyle = UIModalTransitionStyleCrossDissolve;
readerViewController.modalPresentationStyle = UIModalPresentationFullScreen;
[self presentViewController:readerViewController animated:YES completion:nil];
}
答案 0 :(得分:1)
而不是:
NSString *filePath = [NSString stringWithFormat:@"%@/book_%@.pdf", documentsDirectory,comicbook_id];
使用
NSString *filePath = [documentsDirectory stringByAppendingPathComponent:[NSString stringWithFormat:@"book_%@.pdf",comicbook_id]];
答案 1 :(得分:0)
那些不使用ARC且需要Reader视图控制器的人。请到你的项目中的建设阶段---&gt; complie sources - &gt;它会列出.m文件列表请点击哪个.m哪个读者有开放项目,有.m文件并双击那些并写“-fobjc-arc”
自动读者阅读那些感谢你...