【发布时间】:2016-03-17 06:13:16
【问题描述】:
我正在 Titanium 中构建一个 iOS 应用程序。第一个窗口是登录页面。当用户输入他们的用户名和密码时,这些值将被发送到 PHP 文件进行身份验证。
如果用户通过身份验证 - 即他们有唯一的用户名/密码组合,我希望关闭当前窗口并打开新窗口。
值被发送到 PHP 文件并且用户正在被认证;但是,当关闭当前窗口的代码运行 (Titanium.UI.currentWindow.close) 时,会引发错误,指示打开新窗口的文件不存在。不过,引用新窗口的文件确实存在。
我已将似乎导致错误的代码移到许多地方,但结果相同。
var loginReq = Titanium.Network.createHTTPClient();
loginReq.onload = function()
{
var json = this.responseText;
var response = JSON.parse(json);
if (response.logged == true)
{
alert("Welcome " + response.name + ". Your email is: " + response.email);
username.value = '';
password.value = '';
//This creates the new window after user authentication.
var menuPage = Titanium.UI.createWindow({
title: "Menu",
tabBarHidden: false,
url: 'menuPage.js'
});
//This is supposed to close the current window.
Titanium.UI.currentWindow.close();
//This is supposed to open the new window.
menuPage.open();
}
else
{
alert(response.message);
}
};
【问题讨论】:
-
有时
Titanium.UI.currentWindow不会返回当前窗口。尝试在您的网络文件中传递Window或在您的窗口中写入网络的onload 作为回调。
标签: titanium