English 中文(简体)
open iBooks from my app
原标题:

I have some PDF in my app. I want to provide an option to open those PDF in other third party e-readers app that might be installed on the device, like Stanza and iBooks. Dropbox application has successfully implemented this feature and I can t find any information on how to detect what other e-readers are available on the device or what the custom url scheme is for those apps. Any help would be greatly appreciated. thanks in advance guys.

问题回答

iBooks

NSString *stringURL = @"itms-books:";

NSURL *url = [NSURL URLWithString:stringURL];

[[UIApplication sharedApplication] openURL:url];

NSString *stringURL = @"itms-bookss:";

NSURL *url = [NSURL URLWithString:stringURL];

[[UIApplication sharedApplication] openURL:url];

First of all you will need to create a NSURL object like so:

NSURL *url = [NSURL fileURLWithPath:file.FileName];

file.FileName --> your local file path where the document is stored in the local db.

UIDocumentInteractionController    *docController = [UIDocumentInteractionController interactionControllerWithURL:url];

docController.delegate = self;

[docController retain];

[docController presentOpenInMenuFromRect:CGRectZero inView:self.view animated:YES];

The following delegate methods will need to be implemented:

-(void)documentInteractionController:(UIDocumentInteractionController *)controller willBeginSendingToApplication:(NSString *)application
{

}

- (void)documentInteractionController:(UIDocumentInteractionController *)controller didEndSendingToApplication:(NSString *)application
{

}

- (void)documentInteractionControllerDidDismissOpenInMenu:(UIDocumentInteractionController *)controller
{

}

You don t need to detect the other apps, you need to know the url that can open them.

A call like this:

[[UIApplication sharedApplication] openURL:[NSURL URLWithString:@"http://www.apple.com"]];

Tells the phone to open the page in whatever app handles http/html requests which is safari. iBooks has their own url format which hopefully you can track down.

[[UIApplication sharedApplication] openURL:[NSURL URLWithString:@"ebook://iRobot.pdf"]];

NOTE: that s not correct, just meant to illustrate a different url scheme.





相关问题
Code sign Error

I have created a new iPhone application.I have two mach machines. I have created the certificate for running application in iPhone in one mac. Can I use the other mac for running the application in ...

ABPersonViewController Usage for displaying contact

Created a View based Project and added a contact to the AddressBook using ABAddressBookRef,ABRecordRef now i wanted to display the added contact ABPersonViewController is the method but how to use in ...

将音频Clips从Peter改为服务器

我不禁要问,那里是否有任何实例表明从Peit向服务器发送音响。 I m不关心电话或SIP风格的解决办法,只是一个简单的袖珍流程......

• 如何将搜查线重新定位?

我正试图把图像放在搜索条左边。 但是,问题始于这里,搜索条线不能重新布署。

热门标签