I want to open a epub file into ibooks app. I am using this code to load ePub file:
-(void)OpeniBooks
{
NSString *applicationDocumentsDir = [NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES) lastObject];
NSString *storePath = [applicationDocumentsDir stringByAppendingPathComponent:@"/Downloads/Livro.epub"];
NSURL *URL = [NSURL fileURLWithPath:storePath];
if (URL) {
// Initialize Document Interaction Controller
self.documentInteractionController = [UIDocumentInteractionController interactionControllerWithURL:URL];
// Configure Document Interaction Controller
[self.documentInteractionController setDelegate:self];
}
// the file exist
if([[NSFileManager defaultManager] fileExistsAtPath:storePath])
{
NSLog(@"Exist");
}
if (![self.documentInteractionController presentOptionsMenuFromRect:CGRectZero inView:self.view animated:YES]) {
UIAlertView *alertView = [[UIAlertView alloc]initWithTitle:nil message:@"You don't have an app installed that can handle ZIP files." delegate:self cancelButtonTitle:@"Thanks!" otherButtonTitles:nil, nil];
[alertView show];
}
}
- (UIViewController *) documentInteractionControllerViewControllerForPreview: (UIDocumentInteractionController *) controller
{
return self;
}
- (void)documentInteractionController:(UIDocumentInteractionController *)controller willBeginSendingToApplication:(NSString *)application {
NSLog(@"Starting to send this puppy to %@", application);
}
- (void)documentInteractionController:(UIDocumentInteractionController *)controller didEndSendingToApplication:(NSString *)application {
NSLog(@"We're done sending the document.");
}
but the method didEndSendingToApplication never is called and the application crash.
this appears in output :
Unknown activity items supplied: ( { "org.idpf.epub-container" = <504b0304 14000000 0000857c 3f446f61 ab2c1400 00001400 00000800 00006d69 6d657479 70656170 706c6963 6174696f 6e2f6570......
Its possible to call ibooks for loading local epubs or its not possible?
Thanks!
Aucun commentaire:
Enregistrer un commentaire