open iBooks from my app

非 Y 不嫁゛ 提交于 2019-12-01 09:22:50
Vijay-Apple-Dev.blogspot.com

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

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.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!