Issue
Using DocumentViewer on iOS 8 is not rendering PDF files.
Steps to repro
1. Run test case (test.zip)
2. Click on Launch Doc button
3. On the navigation bar press the done button
4. Click on Launch PDF button
Expected result:
After clicking on Launch Doc button the .docx file is rendered in the DocumentViewer and after clicking on Launch PDF button the .pdf file is also shown in the DocumentViewer.
Actual result:
After clicking on Launch Doc button the .docx file is rendered in the DocumentViewer and after clicking on Launch PDF button the .pdf file is not being shown by the DocumentViewer.
Sample code
var win = Ti.UI.createWindow();
// Use a NavigationWindow to create a navigation bar for the window
var navWin = Ti.UI.iOS.createNavigationWindow({window: win});
var navButton = Titanium.UI.createButton({title:'Launch'});
win.RightNavButton = navButton;
var docButton = Titanium.UI.createButton({
title:'Launch Doc',
height:40,
width:200,
top:230
});
win.add(docButton);
var pdfButton = Titanium.UI.createButton({
title:'Launch PDF',
height:40,
width:200,
top:280
});
win.add(pdfButton);
// Create a document viewer to preview a PDF file
docViewer = Ti.UI.iOS.createDocumentViewer();
// Opens the options menu and when the user clicks on 'Quick Look'
// the document viewer launches with an animated transition
navButton.addEventListener('click', function(){
docViewer.show({view:navButton, animated: true});
});
// The document viewer immediately launches without an animation
docButton.addEventListener('click', function(){
docViewer.url = 'test1.docx';
docViewer.show();
});
pdfButton.addEventListener('click', function(){
docViewer.url = 'test.pdf';
docViewer.show();
});
navWin.open();
Additional info
There are reports of this happening on native also apparently related to changes in how to call the UIDocumentInteractionController
http://stackoverflow.com/questions/25430069/uidocumentinteractioncontroller-displaying-blank-pdf
I believe this is this line: https://github.com/appcelerator/titanium_mobile/blob/master/iphone/Classes/TiUIiOSDocumentViewerProxy.m#L28, but that looks similar to the corrected version in the SO post.
reproduced problem on iOS7 as well.
When trying to change url in a document viewer instance, it sometimes doesn't load the respective document in url. Reason is because we are using UIDocumentInteractionController, which according to Apple API documents, is supposed to be a preview controller, and recommended to initialize an instance for every different file previewed. Bug solved by creating new instance every time url is changed for document view.
PR here https://github.com/appcelerator/titanium_mobile/pull/6062
backport PR here https://github.com/appcelerator/titanium_mobile/pull/6064
Tested and verified Document Viewer is displaying PDF files. Environment Mac osx 10.9.4 Maverics Appcelerator Studio, build: 3.4.0.201409112242 Titanium SDK, build: 3.4.0.v20140912160914 acs@1.0.16 alloy 1.5.0-rc install@0.1.7 npm@1.4.23 sudo@1.0.3 titanium 3.4.0-rc2 titanium-code-processor@1.1.1 Xcode6 Device: iPhone 5S iOS8
reopened to change details