大家好,我是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];
}
代替这个:
NSString *filePath = [NSString stringWithFormat:@"%@/book_%@.pdf", documentsDirectory,comicbook_id];
使用
NSString *filePath = [documentsDirectory stringByAppendingPathComponent:[NSString stringWithFormat:@"book_%@.pdf",comicbook_id]];
本文收集自互联网,转载请注明来源。
如有侵权,请联系[email protected] 删除。
我来说两句