【发布时间】:2018-01-08 21:34:58
【问题描述】:
我的 appcelerator 合金应用程序有一个部分在列表视图中显示员工使用的协议列表(大约有 25 个),当点击一行时,它应该在 assets/protocol_pdf 文件夹中打开相应的 PDF 文档。在 iOS 11.2.1 中,文档查看器打开,但不显示 PDF,只显示文件名后跟 PDF 文档(见图)。在 iOS 10 及更早版本中一切正常。
我使用http://www.appcelerator.com/blog/2015/08/appcelerator-pdf-viewer-demo/ 中的代码示例打开了 PDF。
此外,在新的测试项目中使用 appcelerator 文档 (http://docs.appcelerator.com/platform/latest/#!/api/Titanium.UI.iOS.DocumentViewer) 中的确切代码会导致同样的问题。
此时我不确定如何解决该问题。我只能猜测文件的保存位置和访问方式有所不同。任何建议表示赞赏。
我的代码:
function onItemClick(e){
var item = $.listView.sections[e.sectionIndex].items[e.itemIndex];
Ti.API.info('Opening ' + item.properties.file);
if(OS_IOS){
openResourcePDF(item.properties.file);
} else{
Alloy.Globals.Navigator.open("androidPDF", {file: item.properties.file});
}
}
function openResourcePDF(fileName){
var appFile;
appFile = Ti.Filesystem.getFile(Ti.Filesystem.resourcesDirectory, fileName);
var appfilepath = appFile.nativePath;
viewPDF(appfilepath);
}
function viewPDF(appfilepath){
docViewer = Ti.UI.iOS.createDocumentViewer({url:appfilepath});
docViewer.show();
}
【问题讨论】:
-
遇到同样的问题并提交了 Jira 票证:jira.appcelerator.org/browse/AC-5534
标签: javascript titanium appcelerator