V2EX = way to explore
V2EX 是一个关于分享和探索的地方
现在注册
已注册用户请  登录
906
V2EX  ›  程序员

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

  •  
  •   906 · 2013-12-08 13:28:24 +08:00 · 2548 次点击
    这是一个创建于 3813 天前的主题,其中的信息可能已经有所发展或是发生改变。
    本人想在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中的弹出框一直不出来,这是为什么呀?
    2 条回复    1970-01-01 08:00:00 +08:00
    robinWu
        1
    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
        2
    robinWu  
       2013-12-09 17:08:16 +08:00
    <link rel="stylesheet" type="text/css" href="scripts/ext4/resources/css/ext-all.css">
    这个地址要改成应用本地目录的地址
    关于   ·   帮助文档   ·   博客   ·   API   ·   FAQ   ·   实用小工具   ·   1138 人在线   最高记录 6679   ·     Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 · 30ms · UTC 23:14 · PVG 07:14 · LAX 16:14 · JFK 19:14
    Developed with CodeLauncher
    ♥ Do have faith in what you're doing.