1

我正在移动设备中创建 1 个应用程序。

从appdelegate(iphone),我想调用驻留在我的sencha touch控制器中的javascript。有人可以帮我吗?

我真的被困住了。

请帮我。

提前致谢。

4

1 回答 1

0

尝试使用自定义 URL 方案。

Sencha API Docs 将告诉您将以下代码添加到您的应用程序::

Ext.application({
name: 'Sencha',
requires: ['Ext.device.Device'],
launch: function() {
    if (Ext.device.Device.scheme) {
        // the application was opened via another application. Do something:
        alert('Applicaton pened via another application: ' + Ext.device.Device.scheme.url);
    }

    // Listen for future changes
    Ext.device.Device.on('schemeupdate', function(device, scheme) {
        // the application was launched, closed, and then launched another from another application
        // this means onReady will not be called again (because the application is already running in the 
        // background) - but this event will be fired
        alert('Applicated reopened via another application: ' + scheme.url);
    }, this);
}
});

为确保此操作有效,请在 packager.json 文件中添加您在打包应用程序时要使用的自定义 URL,如下所示:

{
...
"rawConfig": "<key>CFBundleURLTypes</key><array><dict><key>CFBundleURLSchemes</key><array><string>sencha</string></array><key>CFBundleURLName</key><string>com.sencha.example</string></dict></array>"
...
}

编辑 :: 目前仅适用于 Sencha Native Packager,不适用于 Phonegap。

于 2013-03-26T19:20:34.970 回答