我正在移动设备中创建 1 个应用程序。
从appdelegate(iphone)中,我想调用驻留在我的sencha touch Controller 中的javascript。有人可以帮助我吗?
我真的被困住了。
请帮助我。
提前致谢。
最佳答案
尝试使用自定义 URL 方案。
Sencha API 文档将告诉您将以下代码添加到您的应用程序中::
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。
关于javascript - 从 Objective C + sencha touch 中调用 javascript 函数,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/15363399/