Search code examples
iosuiactionsheetcordova

NativeControls or ActionSheet Cordova plugin documentation?


I've seen a lot of documentation on using the TabBar or ToolBar in the NativeControls plugin, however, almost zero for using the ActionSheet.

I followed the README for ActionSheet plugin: https://github.com/phonegap/phonegap-plugins/tree/master/iOS/ActionSheet

I've got it working sort of, but the examples create buttons that don't do anything. I'd like to create an ActionSheet that has 'Tweet' button, 'Share on Facebook' button, "Email" button and Cancel and obviously fires off Javascript to access the Twitter and Facebook-Connect functionality.

Has anyone used NativeControls/ActionSheet plugins as a way to create share buttons? Or any type of buttons really that have some sort functionality. I'm just looking for some sort of template.

I haven't had success creating an ActionSheet from the NativeControls plugin. I'm using Cordova 1.6.1, Xcode 4.3.2 and the latest plugins from GitHub.

Thanks in advance!


Solution

  • An app might have a button that with onclick="selectAction();" If the user selects "Camera" then capturePhoto() will be called. If they select "Photo Library" then getPhoto() will be called.

    function selectAction() {
    var actionSheet = window.plugins.actionSheet;
    actionSheet.create('Select Image Source', ['Camera', 'Photo Library', 'Cancel'], function(buttonValue, buttonIndex) {
       switch (arguments[1]) {
           case 0:
           capturePhoto();
           break;
           case 1:
           getPhoto(pictureSource.PHOTOLIBRARY);
           break;
           default:
           console.log('selectAction default case says: go back to page1');
       }
       }, {cancelButtonIndex: 2}); 
    } //End Function