View Full Version : Sencha Touch 2.0 PR3 not working in a UIWebView (iphone)

19 Dec 2011, 12:47 PM
Hi Guys,

my sample app (copy/paste from the getting started) works perfect on the Mobile Safari, but when I open it in a UIWebView inside my app it doesn't work. The web app is already on a server, its not built-in the app.

Any hints of how to solve that?



19 Dec 2011, 1:46 PM
what doesn't work?

19 Dec 2011, 4:18 PM
- Are you using PhoneGap, Sencha Native, or your own implementation?
- Are you using Ext.Loader? (there are sometimes issues with this).

19 Dec 2011, 6:16 PM
I'm not using phonegap.
It's just a simple hello world.
Its in my own implementation using a UIWebView.

It loads a blank screen. The web app loads perfect in the Mobile Safari but not in my UIWebView.

20 Dec 2011, 12:16 AM
I'm afraid I cannot help you without the source of the actual native application.

Chances are, you are not including the correct JS, or not doing it at the correct time. Or you have an error.

I've done this several times with ST.

20 Dec 2011, 1:39 PM

my web app code is:

name: 'Sencha',

launch: function() {
Ext.create("Ext.TabPanel", {
fullscreen: true,
tabBarPosition: 'bottom',

items: [
title: 'Home',
iconCls: 'home',
cls: 'home',
html: [
'<img width="65%" src="http://staging.sencha.com/img/sencha.png" />',
'<h1>Welcome to Sencha Touch</h1>',
"<p>You're creating the Getting Started app. This demonstrates how ",
"to use tabs, lists and forms to create a simple app</p>",
'<h2>Sencha Touch (2.0.0pr1)</h2>'
xtype: 'list',
title: 'Blog',
iconCls: 'star',

itemTpl: '{title}',
store: {
fields: ['title', 'url'],
data: [
{title: 'Ext Scheduler 2.0', url: 'ext-scheduler-2-0-upgrading-to-ext-js-4'},
{title: 'Previewing Sencha Touch 2', url: 'sencha-touch-2-what-to-expect'},
{title: 'Sencha Con 2011', url: 'senchacon-2011-now-packed-with-more-goodness'},
{title: 'Documentation in Ext JS 4', url: 'new-ext-js-4-documentation-center'}

and my native code is:

@implementation ContactViewController

- (id)initWithNibName:(NSString *)nibNameOrNil bundle:(NSBundle *)nibBundleOrNil
self = [super initWithNibName:nibNameOrNil bundle:nibBundleOrNil];
if (self) {
self.title = @"Test" ;
return self;

#pragma mark - View lifecycle

- (void)viewDidLoad {
[super viewDidLoad];
[self loadWebView] ;

- (void)loadWebView {
NSURL *url = [NSURL URLWithString:@"http://feedback.mobihouse.com/"];
_webView = [[UIWebView alloc] initWithFrame:self.view.frame] ;
_webView.scalesPageToFit = NO;
[_webView loadRequest:[NSURLRequest requestWithURL:url]];
[self.view addSubview:_webView] ;

as you can see its a simple UIWebView. I don't know whats happening.


20 Dec 2011, 2:52 PM
Does it work in a browser? Which Js file are you including in your index.html file?

20 Dec 2011, 3:55 PM
the html code is:

<!DOCTYPE html>
<link rel="stylesheet" href="touch/resources/css/sencha-touch.css" type="text/css">
<script type="text/javascript" src="touch/sencha-touch-all.js"></script>
<script type="text/javascript" src="app.js"></script>
</html>it runs in the browser but doesn't run in the UIWebView.

20 Dec 2011, 3:56 PM
it runs in the browser but doesn't run in the UIWebView. I don't know why.

20 Dec 2011, 6:46 PM
I suggest you use something like weinre to track down the issue. http://phonegap.github.com/weinre/

20 Dec 2011, 7:35 PM
Problem solved. I had to add:

Ext.application({ viewport: { autoMaximize: false }, ...});

but I don't know why.


16 Jan 2012, 5:34 AM
Hi, I have a similar problem, just that I'm not trying to load the HTML (and the sencha sources) from an external server, but inside the application. I have the JS/CSS files like app bundles.

Any idea about how i have to add the library?

Thanks in advance.