PDA

View Full Version : My application doesn't load when I test it for the iPhone 4g



tysoncadenhead
13 Oct 2010, 5:36 PM
Okay, so this may or may not be an issue with Sencha Touch, but I'm not really sure where else to turn. I've built an iPhone / Android App using Sencha Touch and Phone Gap. I'm previewing it using xCode on my Mac and everything looks fine on the older iPhone emulator and on the iPad emulator, but for some reason, the iPhone 4G emulator doesn't load anything except the background image that I'm applying to the body tag in my stylesheet. The place where I'm instantiating the application is pretty straightforward:



Ext.setup({
onReady: function(){

if (window.device){
MyApp.config.uuID = device.uuid;
}

// Initialize the application
new MyApp.Application();
}
});


But like I said, it doesn't load. I've done some debugging and I can't even fire an alert or log inside the ready block on the iPhone 4G. Has anyone seen anything like this?

evant
13 Oct 2010, 5:38 PM
To clarify, you're saying it only doesn't work with PhoneGap? You might get more mileage posting on a PhoneGap discussion group if that's the case.

tysoncadenhead
13 Oct 2010, 6:08 PM
I sent it there too... I just thought since the issue is with the Ext.onReady event firing someone here might have run into it too.

carok
19 Oct 2010, 3:03 AM
Hi Tyler, just wondering if you got anywhere with this?

I'm having a similar problem, my app (sencha and phonegap) runs in the simulator no problem (iPhone Simulator 4, 4.1, 4.2) and in Safari but on the actual device (iPhone 3GS running iOS 4.2 beta) I just get the Page loaded with no content (if I put some test HTML into the index.html page I can see that).

From debugging Sencha's onReady function is never getting called when running on the device and I have no idea why?

sandor
19 Oct 2010, 3:52 AM
I'm not sure if this applys here, since i never used Phonegap - but yesterday i was toying around with Sencha Mobile and Xcode using some simple UIwebView stuff there. First i had that problem also: the app is not showing up, only the index.html page. I found following things/solutions: First - be sure that your JS files will not be compiled again by Xcode (Xcode will try to do this if you are loading the Sencha JS files in your Xcode project). Second: be sure that all of your files will land inside the bundles folder of your Xcode project (you have to make sure that the files are not only referenced).

Hope this helps?

Sandor

tysoncadenhead
19 Oct 2010, 3:58 AM
I actually did get somewhere with it. I put the Ext.onReady inside of a document.onload function like this:



<head>
<script>
BodyOnLoad = function(){
Ext.onReady(function(){
// Your code to execute
});
}
</script>
</head>
<body onload="BodyOnLoad()">
</body>


And it loads fine now.

carok
19 Oct 2010, 5:28 AM
Thanks Tyson, that's working for me too!

gabrielstuff
22 Oct 2010, 8:03 AM
For it loads... but not in the right place. Evrything get broken.
Here is the snippets :


<script>
BodyOnLoad = function(){
Ext.onReady(function(){

alert('ready');

app.storeActu = new Ext.data.Store({
autoLoad: true,
model: 'Actu',
proxy: {
url: app.streamGap,
type: 'scripttag',
reader: {
root: 'data'
}
}
});
app.storeActivatedItems = new Ext.data.Store({
autoLoad: true,
model: 'activeId',
proxy: {
type: 'scripttag',
url: app.stream,
reader:
{
type: 'json',
root: 'dock'
}
}
});
app.animation = undefined;
app.selectedTeam = undefined;
app.iToUnM = '';
app.Main.init();
});
}
</script>


and the body :


<body onload="BodyOnLoad()"/></body>

The alert ready fires twice... and the error from safari is :


it correspond to this ext-touch-debug.js with sencha touch 0.95

TypeError: Result of expression 'this.targets' [undefined] is not an object.


addEventListener : function(dom, ename, fn, o) {
if(!this.targets[ename]) {
return;
}

Any help would be greatly appreciate !

Thanks

carok
25 Oct 2010, 8:01 AM
Sorry for taking so long to reply, could it be the "app.Main.init();" is causing your method to fire twice?

gabrielstuff
25 Oct 2010, 8:06 AM
Yes Actually, I solved it using this :



function onBodyLoad() {
document.addEventListener("deviceready",initSenchaCode,false);
};
function initSenchaCode() {
Ext.setup({
onReady:function(){

app.storeActu=new Ext.data.Store({autoLoad:true,model:"Actu",proxy:{url:app.stream,type:"scripttag",reader:{root:"data"}}});

app.animation=undefined;
app.selectedTeam=undefined;
app.iToUnM="";
app.Main.init()}});
};
</script>



And adding the code :


</head>
<body onload="onBodyLoad()"> </body>
</html>

into index.html.

Still, it load up quiete slowly :(

Thanks for the reply !

topquark
6 Mar 2011, 10:37 PM
I was experiencing the same problem that tysoncadenhead was having - the app would load, but wouldn't get past showing whatever was hardcoded in the body of my index.html. It was strange though, it only happened in the Simulator and it only happened sometimes (seemed to happen most frequently when testing to iPad 4).

I spent hours trying to figure out wtf. Hopefully my solution will save someone else similar headaches.

It involves editing the sencha-touch-debug.js file.

I'm using version 1.0.1a.

Sencha runs some tests to see what features are supported. See where Ext.supports gets defined.

Within those tests, sometimes, a couple of the tests were failing when trying to use the variable div.firstChild or div.lastChild. I still don't know why.

At any rate, I wrapped the call to the tests in a try{} and the problem disappeared.

Around line 4745, change:


this[test.identity] = test.fn.call(this, doc, div);to:



try{
this[test.identity] = test.fn.call(this, doc, div);
}
catch(e){
this[test.identity] = false;
}
Is this a bug in Sencha Touch?

alikic
19 Apr 2011, 5:28 AM
There is an explanation of this iOS issue, along with a workaround, at

http://stackoverflow.com/questions/4586022/is-there-a-bug-with-using-innerhtml-inside-a-uiwebview-within-a-native-iphone-app