IOS开发中使用UIWebview + extjs遇到的问题,求达人给点意见

2013-12-08 13:28:24 +08:00
 906
本人想在IOS应用中使用源生代码,UIWebview + Extjs进行部分功能界面的开发,但是一直没看到Extjs的运行结果,故求教。

工程的结果中Extjs放在工程根目录下,scripts的目录结构如下:
scripts
-- app.js
-- index.html
-- ext4
--- ext-all-debug.js
--- resource
----------------------华丽分割线-----------------------
UIWebview的代码如下:
NSString* jspath = [[NSBundle mainBundle] pathForResource:@"scripts/index" ofType:@"html"];
NSString* htmlstr = [NSString stringWithContentsOfFile:jspath
encoding:NSUTF8StringEncoding
error:nil];
NSString *basePath = [[NSBundle mainBundle] resourcePath];
NSLog(@"basepath=%@",basePath);
NSURL * baseURL = [NSURL fileURLWithPath:basePath];
[_webView loadHTMLString:htmlstr baseURL:baseURL];
----------------------华丽分割线-----------------------
html代码如下:
<html>
<head>
<title>Hello Ext</title>
<link rel="stylesheet" type="text/css" href="scripts/ext4/resources/css/ext-all.css">
<script type="text/javascript" src="scripts/ext4/ext-all-debug.js"></script>
<script type="text/javascript" src="app.js"></script>
</head>
<body>
<b>test</b>
</body>
</html>
----------------------华丽分割线-----------------------
app.js代码如下:
Ext.application({
name: 'HelloExt',
launch: function() {
Ext.create('Ext.container.Viewport', {
layout: 'fit',
items: [
{
title: 'Hello Ext',
html : 'Hello! Welcome to Ext JS.'
}
]
});
}
});



在模拟器中执行的时候,这个app.js中的弹出框一直不出来,这是为什么呀?
2555 次点击
所在节点    程序员
2 条回复
robinWu
2013-12-09 17:07:33 +08:00
NSString* jspath = [[NSBundle mainBundle] pathForResource:@"scripts/index" ofType:@"html"];
改成
NSString* jspath = [[NSBundle mainBundle] pathForResource:@"index" ofType:@"html"];
robinWu
2013-12-09 17:08:16 +08:00
<link rel="stylesheet" type="text/css" href="scripts/ext4/resources/css/ext-all.css">
这个地址要改成应用本地目录的地址

这是一个专为移动设备优化的页面(即为了让你能够在 Google 搜索结果里秒开这个页面),如果你希望参与 V2EX 社区的讨论,你可以继续到 V2EX 上打开本讨论主题的完整版本。

https://www.v2ex.com/t/92271

V2EX 是创意工作者们的社区,是一个分享自己正在做的有趣事物、交流想法,可以遇见新朋友甚至新机会的地方。

V2EX is a community of developers, designers and creative people.

© 2021 V2EX