首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >appcelerator如何从另一个窗口关闭索引窗口

问appcelerator如何从另一个窗口关闭索引窗口
EN

Stack Overflow用户
提问于 2016-05-26 14:59:39
回答 2查看 548关注 0票数 0

所有人

我用钛合金,我有两个窗口,index.js和main.js。

当应用程序运行时,index.js的窗口将被打开,索引中有一个按钮,如果有人单击该按钮,则main将被打开。Main有另一个按钮,用于关闭索引。

如您所见,我正试图关闭主窗口中的索引窗口。

在IOS中一切正常,但是当我在Android上测试它时,我发现了一个奇怪的问题:当我单击main.js中的按钮关闭索引窗口时,所有的窗口(索引和主窗口)都关闭了。

我尝试了许多方法,比如使用Ti.APP.触发器/Ti.APP.addEventListener并将$.index或回调函数发送到main.js。

有人能帮我吗谢谢。

EN

回答 2

Stack Overflow用户

回答已采纳

发布于 2016-06-06 11:03:35

您的解决方案是设置此属性:exitOnClose = false,由@genocsb回答。它只能在Android上使用。

实际上,这个属性告诉在关闭窗口时哪个窗口应该关闭应用程序。因此,默认情况下,第一个窗口具有它的属性exitOnClose = true。

在你的例子中,做这样的事情:

- index.js

代码语言:javascript
复制
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

代码语言:javascript
复制
$.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;
});
票数 0
EN

Stack Overflow用户

发布于 2016-05-26 23:21:25

在index.js中使用这个

$.index.exitOnClose = false

票数 1
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/37464521

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档