Question

Is there a way to toggle the DocumentInteractionController on Titanium i'm not finding it in any way

i think this is what i need

- (UIDocumentInteractionController *) setupControllerWithURL: (NSURL) fileURL
    usingDelegate: (id <UIDocumentInteractionControllerDelegate>) interactionDelegate {

    UIDocumentInteractionController *interactionController =
        [UIDocumentInteractionController interactionControllerWithURL: fileURL];
    interactionController.delegate = interactionDelegate;

    return interactionController;
}
Was it helpful?

Solution

You're looking for Ti.UI.iOS.createDocumentViewer(). That API uses UIDocumentInteractionController under the covers.

var win = Ti.UI.createWindow({
    backgroundColor: '#fff'
});
win.open();

// Download a PDF.
var file = Ti.Filesystem.getFile(Ti.Filesystem.applicationDataDirectory, 'casestudy_bracket.pdf'),
    client = Ti.Network.createHTTPClient({
    onload: function() {
        // Open a doc viewer.
        var docViewer = Ti.UI.iOS.createDocumentViewer({
            url: file.nativePath
        });
        docViewer.show({ animated: true });
    },
    onerror: function() {
        alert('Well, shoot.')
    }
});
client.open('GET', 'http://www.appcelerator.com.s3.amazonaws.com/pdf/casestudy_bracket.pdf');
client.file = file;
client.send();

OTHER TIPS

Prefer this it helps you.

In this blog there is source code is available to open document in ios-documentviewer.

Appcelerator Blog

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top