ios – 在UIWebView中添加“在iBooks中打开”

我正在为网站开发一个包装器应用程序.基本上,它在UIWebView中打开网站的移动版本.网站上的某些链接指向PDF.

当在Safari中打开同一站点并点击PDF链接时,PDF上会显示一条带有“在iBooks中打开”的漂亮黑条纹.如下图所示:

我怎么能在我的应用程序中实现相同的条纹?

编辑:

我不是在询问如何在半透明背景上创建黑色按钮.

我有兴趣重现整个工作流程:

>用户导航到PDF
>当且仅当安装了iBooks应用程序(或任何其他PDF查看器)时,才会弹出条带(视图).
>点击弹出窗口中的按钮将文档传输到该应用程序并打开应用程序.

解决方法

要检查iBooks是否已安装,您可以致电:
BOOL iBooksInstalled = [[UIApplication sharedApplication] canopenURL:[NSURL URLWithString:@"ibooks://"]];

您可以使用以下内容显示应用程序列表(为什么仅限于iBooks?;)):

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

请注意,这不适用于iOS模拟器,除非您创建了一个阅读PDF的应用程序!

如果您真的只想让选项让我们在iBooks中打开PDF,您可能想尝试将文件的URL附加到@“ibooks://”方案或iBooks提供的其他两种方案之一(它适用于iBook商店中的书籍,但我不确定它是否适用于其他网址)@“itms-books://”和@“itms-bookss://”.然后你可以这样做:

NSURL *iBooksURLScheme = [NSURL URLWithString:@"ibooks://"];
Nsstring *fileURLString = // your file URL as *string*
NSURL *finalURL = [iBooksURLScheme URLByAppendingPathComponent:fileURLString];

[[UIApplication sharedApplication] openURL:finalURL];

相关文章

UITabBarController 是 iOS 中用于管理和显示选项卡界面的一...
UITableView的重用机制避免了频繁创建和销毁单元格的开销,使...
Objective-C中,类的实例变量(instance variables)和属性(...
从内存管理的角度来看,block可以作为方法的传入参数是因为b...
WKWebView 是 iOS 开发中用于显示网页内容的组件,它是在 iO...
OC中常用的多线程编程技术: 1. NSThread NSThread是Objecti...