It is continuation of open iBooks from my app I did try https://developer.apple.com/library/ios/documentation/UIKit/Reference/UIDocumentInteractionController_class/Reference/Reference.html but it is hard to understand with out code sample.
I have iPhone app, that have Web View.
After starting the app Web View opens custom PDF, and this is working fine.
User wil not read that PDF from my app, so I wont to add button that will open that PDF in iBooks (because iBooks have search and lost of other features…).
I have Toolbar on bottom with button for opening my PDF in iBooks.
And this is my problem, I do not have code for opening my PDF in iBooks.
ViewControler.h
#import <UIKit/UIKit.h>
@interface BG_ViewController : UIViewController
{
IBOutlet UIWebView *myWebView;
}
- (IBAction)openInIBooks:(id)sender;
@end
ViewControler.m
#import "BG_ViewController.h"
@interface BG_ViewController ()
@end
@implementation BG_ViewController
- (void)viewDidLoad
{
[super viewDidLoad];
NSString *path = [[NSBundle mainBundle] pathForResource:@"MyBOOK" ofType:@"pdf"];
NSURL *targetURL = [NSURL fileURLWithPath:path];
NSURLRequest *request = [NSURLRequest requestWithURL:targetURL];
[myWebView loadRequest:request];
}
- (void)didReceiveMemoryWarning
{
[super didReceiveMemoryWarning];
// Dispose of any resources that can be recreated.
}
- (IBAction)openInIBooks:(id)sender
{
NSLog(@"Clicked\n");
// CODE ???
}
@end
What code need to be added to - (IBAction)openInIBooks:(id)sender so that it will open MyBOOK.pdf ???
Best that I have is:
NSString *stringURL = @"itms-books:";
NSURL *url = [NSURL URLWithString:stringURL];
[[UIApplication sharedApplication] openURL:url];
But this will just open iBooks app, but with out MyBOOK.pdf.
I tried just to add "itms-books:MyBOOK.pdf", but it is not working :-(