我正在为一个网站开发一个包装应用程序。基本上,它在 UIWebView 中打开网站的移动版本。网站上的一些链接指向 PDF。
当在 Safari 中打开同一网站并点击 PDF 链接时,PDF 上会显示一条漂亮的黑色条纹,上面写着“在 iBooks 中打开”。就像下面的图片一样:
如何在我的应用程序中实现相同外观的条纹?
EDIT:
I am not询问如何在半透明背景上创建黑色按钮。
我有兴趣重现整个工作流程:
- 用户导航至 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];
请注意,除非您制作了一个可以读取 PDF 的应用程序,否则这在 iOS 模拟器上不起作用!
如果您确实只想提供让 PDF 在 iBooks 中打开的选项,您可能需要尝试将文件的 URL 附加到 @"ibooks://" 方案或 iBooks 提供的其他两个方案之一(适用于 iBook Store 中的书籍,但我不确定它是否也适用于其他 URL,即 @"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];
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)