1

它不起作用,因为我没有在项目中使用 ARC,这是我的代码

在下载和保存 pdf 时

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];

在向我的读者检索时,我继续

NSArray *paths = NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES); 
NSString *documentsDirectory = [paths objectAtIndex:0]; 
NSString *comicbook_id = [[NSUserDefaults standardUserDefaults]stringForKey:@"comicbook_id"]; 
NSString *filePath = [documentsDirectory stringByAppendingPathComponent:[NSString stringWithFormat:@"book_%@.pdf",comicbook_id]];

NSLog(@"date==>%@",documentsDirectory);
NSString *phrase = nil;
ReaderDocument *document = [ReaderDocument withDocumentFilePath:filePath password:phrase];
NSLog(@"document==>%@",document);
if (document != nil) {
   ReaderViewController *readerViewController = [[ReaderViewController alloc] initWithReaderDocument:document];
   readerViewController.delegate = self;
   readerViewController.modalTransitionStyle = UIModalTransitionStyleCrossDissolve;
   readerViewController.modalPresentationStyle = UIModalPresentationFullScreen;
   [self presentViewController:readerViewController animated:YES completion:nil];
}
4

0 回答 0