我正在钛中构建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作为回调。 – Swanand