PDA

View Full Version : 2 problems at once ;-)



KevinGorjan
16 Jun 2011, 11:34 PM
Hello everyone, I'm new to Sencha Touch and Phonegap and I could need your help ;)

Problem 1:
I build an app in Sencha and the layout is perfect. but when I combined it with phonegap, it went wrong. the moment i touch the iphone in the simulator, the complete layout (viewport) jumps up a little bit. What could be the problem?

Problem 2:
I'm using the localstorage for input of a form. it al works well, but i also want to save a base64 image to the store. But i dont know how to do this, because the image isn't part of the form. i have to get the scr from the image from phonegap to the model for storing it.

Here is mine code:
the Model

Ext.regModel("arcc.models.Request", {
fields: [
{name: "id", type: "int"},
{name: "naam", type: "string"},
{name: "functie", type: "string"},
{name: "bedrijf", type: "string"},
{name: "email", type: "string"},
{name: "Base", type: "boolean"},
{name: "Belgacom", type: "boolean"},
{name: "Mobistar", type: "boolean"},
{name: "Andere", type: "boolean"},
{name: "aantal_gsms", type: "int"},
{name: "aantal_wagens", type: "int"},
{name: "commentaar", type: "string"},
{name: "image", type: "binary"}
], validations: [
{type: 'presence', name: 'naam', message:"Gelieve een naam op te geven"},
{type: 'presence', name: 'functie', message : "Gelieve een functie in te geven"},
{type: 'presence', name: 'bedrijf', message : "Gelieve een bedrijf in te geven"},
{type: 'format', name: 'email', matcher: /^[a-zA-Z0-9._-]+@[a-zA-Z0-9.-]+\.[a-zA-Z]{2,4}$/, message:"Verkeerd emailadres"},
]
});

the submit handler

xtype: 'button',
text: "Verzenden",
ui: "confirm",
handler: function() {
console.log(arcc.views.detailForm.getValues());
var model = Ext.ModelMgr.create(arcc.views.detailForm.getValues(),'arcc.models.Request');
var errors = model.validate(), message = "";

if(errors.isValid()) {
arcc.stores.requestStore.add(model);
arcc.stores.requestStore.sync();

uploadAndMail();
//arcc.views.detailForm.reset();
arcc.views.viewport.setActiveItem(arcc.views.photoCard), {type:'slide', direction:'right'};
}
else {
Ext.each(errors.items,function(rec,i){
message += rec.message+"<br>";
});
Ext.Msg.alert("Controleer even:", message, function(){});
return false;
}
}

thank you for your help

KevinGorjan
18 Jun 2011, 2:16 AM
Nobody?

Jack9
18 Jun 2011, 2:13 PM
First of all, posting at PST 2:30am Friday, you aren't likely to get a response for a couple days.


That being said, I've actually deployed on PhoneGap so I'll give #1 a shot.

Have you profiled the memory usage? If you wrap it up in an XCode PhoneGap project, attach the Instruments.app to your emulator process (or hardware if you are deploying it directly to the iphone/ipad), you might see that the memory is a problem and components are simply not in memory anymore...which leads to strange layout and behaviors.

As for the "jumping", create a simple fullscreen mini-test app and ensure it's not the device or deployment method.

After that, start stripping out parts of the app until you can find the culprit imo.



#2
So what you want is to combine phonegap's api with sencha-touch. I've wanted to do this, but not had need yet. I would suggest a globally accessible way, in your sencha-touch app to reach into the store...oh we already have that. Ext.getCmp('idofthestore')* Now you can manipulate the data DIRECTLY. This had nothing to do with the model, so without more information/code I can't really give any more help. Also, I am not familiar enough with how to get images using PhoneGap's api so I can't help with that either.

*You do have to hardcode an ID for the store so you can find it, of course.

steve1964
18 Jun 2011, 3:23 PM
For problem 1, if your using phonegap 0.9.5.1 it's a bug of this release, it was just fixed but you have to recompile phonegap:
https://github.com/phonegap/phonegap-iphone

Phonegap related issue:
https://github.com/phonegap/phonegap-iphone/issues/40

KevinGorjan
20 Jun 2011, 12:27 AM
@steve1964:

Thx, thats solved the first problem.

About the second problem, I solved it by using this in the submit:

store.add({name: Ext.getCmp('name'),
});

KevinGorjan
20 Jun 2011, 12:29 AM
@steve1964:

Thx, thats solved the first problem.

About the second problem, I solved it by using this in the submit:


store.add({name: Ext.getCmp('name'),
functie: Ext.getCmp('functie'),
...});

store.sync();

Thx for your help everybody