csaunders
csaunders

Reputation: 1742

PhoneGap application not .live('tap') events on iOS

I have an application that is using jquery, jquerymobile and spine.js running on phonegap (0.9.5.1) and have been having some issues getting it to work properly on iOS.

The application should be launching the camera when a div is tapped. In my controller I have it so that it does something similar to the following:

myController = Spine.Controller.create({
    events: {"tap .take-picture": "takePic"},

    takePic: function(){
        var self = this;
        navigator.camera.getPicture(function(data){
            self.doStuffWith(data);
        }, 
        null,
        {quality: 50, destinationType: Camera.DestinationType.DATA_URL, sourceType: Camera.PictureSourceType.CAMERA})
    },

    doStuffWith: function(data){
        // Doing stuff with said data
    }
});

What is really confusing me, is that this code works properly on Android. Are there some kind of iOS quirks that make it so that tap events aren't sent off properly?

Upvotes: 0

Views: 979

Answers (2)

Peter Kazazes
Peter Kazazes

Reputation: 3628

I think that you are trying to use the Android phonegap js within the iPhone app. You need to make sure that you are including the right phonegap.js for the platform you are developing. Although they share the same name, each version of phonegap is tailored to its host OS.

Upvotes: 2

Shazron
Shazron

Reputation: 2478

This could be several things:

  1. You are testing this in the iOS Simulator. There is no Camera in the Simulator, you don't have a fail callback specified, but there is a bug (I believe) in the API where it doesn't call the fail callback if the source type is not available anyway. You should see this ("Source Type Not Available") in the Run Log (Cmd-Shift-R).

  2. On a device, I tested your code separately, and ran it in deviceReady(), it runs - so the API call seems to be correct. I added a touch handler to a button to call the code also, so it appears tap events are working. So based on these tests (on a device):

(a) the API call works

(b) tap events work

Which leads me to the conclusion that the bug is outside of those two possibilities.

Upvotes: 0

Related Questions