I am developing a wrapper application for a site. Basically, it opens mobile version of a site in UIWebView. Some links on the site point to PDFs.
When the same site is opened in Safari and a link to PDF is tapped a nice black stripe with "Open in iBooks" is shown over the PDF. Like on the picture below:
How could I implement the same looking stripe in my app?
EDIT:
I am not asking about how to create a black button on translucent background.
I am interested in reproducing the whole workflow:
To check if iBooks is installed you can call:
BOOL iBooksInstalled = [[UIApplication sharedApplication] canOpenURL:[NSURL URLWithString:@"ibooks://"]];
You can present a list of of applications (why limit to iBooks only? ;) ) using:
//use the UIDocInteractionController API to get list of devices that support the file type
NSURL *pdfURL = // your pdf link.
UIDocumentInteractionController *docController = [UIDocumentInteractionController interactionControllerWithURL:pdfURL];
//present a drop down list of the apps that support the file type, click an item in the list will open that app while passing in the file.
[docController presentOpenInMenuFromRect:CGRectZero inView:self.view animated:YES];
Note that this doesn't work on the iOS Simulator unless you made an app that reads PDFs!
If you really want to only give the option to let the PDF to be opened in iBooks, you might want to try appending the file's URL to the @"ibooks://" scheme or the one of the other two schemes that iBooks provide (which work for books in the iBook Store but I'm not sure if it also works for other URLs) which are @"itms-books://" and @"itms-bookss://". You can then do something like:
NSURL *iBooksURLScheme = [NSURL URLWithString:@"ibooks://"];
NSString *fileURLString = // your file URL as *string*
NSURL *finalURL = [iBooksURLScheme URLByAppendingPathComponent:fileURLString];
[[UIApplication sharedApplication] openURL:finalURL];
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With