所有人
我用钛合金,我有两个窗口,index.js和main.js。
当应用程序运行时,index.js的窗口将被打开,索引中有一个按钮,如果有人单击该按钮,则main将被打开。Main有另一个按钮,用于关闭索引。
如您所见,我正试图关闭主窗口中的索引窗口。
在IOS中一切正常,但是当我在Android上测试它时,我发现了一个奇怪的问题:当我单击main.js中的按钮关闭索引窗口时,所有的窗口(索引和主窗口)都关闭了。
我尝试了许多方法,比如使用Ti.APP.触发器/Ti.APP.addEventListener并将$.index或回调函数发送到main.js。
有人能帮我吗谢谢。
发布于 2016-06-06 11:03:35
您的解决方案是设置此属性:exitOnClose = false,由@genocsb回答。它只能在Android上使用。
实际上,这个属性告诉在关闭窗口时哪个窗口应该关闭应用程序。因此,默认情况下,第一个窗口具有它的属性exitOnClose = true。
在你的例子中,做这样的事情:
- index.js
Alloy.Globals.Index = $.index;
Alloy.Globals.Index.open();
// If you will do this and press back button on index screen, then you will land to splash screen.
// Alloy.Globals.Index.exitOnClose = false;- main.js
$.button.addEventListener('click', function (){
$.main.exitOnClose = true; // setting it to true will cause your app to close from main.xml screen on back button press
Alloy.Globals.Index.exitOnClose = false; // setting it to false here will ensure that you will not land to splash screen if back button is pressed.
Alloy.Globals.Index.close();
Alloy.Globals.Index = null;
});发布于 2016-05-26 23:21:25
在index.js中使用这个
$.index.exitOnClose = false
https://stackoverflow.com/questions/37464521
复制相似问题