2010-07-29 118 views
3

我在我的应用程序中有一些PDF。我想提供一个选项,可以在设备上安装的其他第三方电子阅读器应用程序中打开这些PDF,例如Stanza和iBooks。 Dropbox应用程序已成功实现此功能,并且找不到有关如何检测设备上可用的其他电子阅读器的信息或者这些应用程序的自定义url方案。任何帮助将不胜感激。在此先感谢你们。从我的应用程序打开iBooks

+0

[如何在iPad上以编程方式启动iBooks电子阅读器?](http://stackoverflow.com/questions/2594321/how-to-launch-ibooks-e-reader-programmatically-on-ipad) – richq 2011-06-10 16:00:53

回答

-1

你不需要检测其他应用程序,你需要知道可以打开它们的URL。

像这样的电话:

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

告知手机打开任何应用程序处理HTTP/HTML请求这是Safari浏览器的页面。 iBooks拥有自己的网址格式,希望您可以追踪。

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

注意:这是不正确的,只是为了说明不同的网址方案。

2

的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]; 
0

所有你需要创建一个NSURL对象,像这样的第一:

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

下面的委托方法将需要实现:

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

} 

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

} 

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

} 
相关问题