Warning: file_get_contents(/data/phpspider/zhask/data//catemap/4/macos/9.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Titanium 从Tianium IOS7中的另一个js文件关闭NavigationWindow(模式)_Titanium_Appcelerator_Titanium Mobile_Appcelerator Mobile_Titanium Alloy - Fatal编程技术网

Titanium 从Tianium IOS7中的另一个js文件关闭NavigationWindow(模式)

Titanium 从Tianium IOS7中的另一个js文件关闭NavigationWindow(模式),titanium,appcelerator,titanium-mobile,appcelerator-mobile,titanium-alloy,Titanium,Appcelerator,Titanium Mobile,Appcelerator Mobile,Titanium Alloy,我正在将当前项目迁移到3.1.3。我需要一个模式窗口上的关闭按钮,所以我必须使用一个导航窗口,正如IOS7迁移指南中建议的那样。这是我的 btnSubscription.addEventListener('click', function(e) { Ti.API.info('Subscription Button Clicked.'); openWindow("paymentsubscription.js", "Subscription"); }); function openWindow(u

我正在将当前项目迁移到3.1.3。我需要一个模式窗口上的关闭按钮,所以我必须使用一个导航窗口,正如IOS7迁移指南中建议的那样。这是我的

btnSubscription.addEventListener('click', function(e) {
Ti.API.info('Subscription Button Clicked.');
openWindow("paymentsubscription.js", "Subscription");
});

function openWindow(url, title) {
var win = Ti.UI.createWindow({
    url : url,
    backgroundColor : 'white',
    modal : true,
    title : title
});


if (Titanium.Platform.osname !== "android") {
var winNav = Ti.UI.iOS.createNavigationWindow({
    modal: true,
    window: win
});
}
if (Titanium.Platform.osname !== "android") {
    winNav.open();
}
else {
    win.open();
}
}
现在在paymenttransaction.js上,我以前在使用Tianium 2.x时就是这么做的

var mainWindow = Ti.UI.currentWindow;

var mainWinClose = Ti.UI.createButton({
style : Ti.UI.iPhone.SystemButtonStyle.DONE,
title : 'close'
});

if (Titanium.Platform.osname !== "android") {
    mainWinClose.addEventListener('click', function() {"use strict";
mainWindow.close();
});
responseWindow.setRightNavButton(responseWinRightNavButton);
mainWindow.setRightNavButton(mainWinClose);
}
我面临的问题是,在IOS的情况下,我需要关闭winNav,而不再获胜。在paymenttransaction.js中,我以前使用过

var mainWindow = Ti.UI.currentWindow;

但是现在我需要关闭导航窗口(winNav),这不再有效。有什么办法可以这样做吗。NavigationWindow是否有Ti.UI.currentWindow等效项

您没有正确使用navigationWindow。在使用窗口时,不应该对窗口调用open()

您正在寻找:

`winNav.openWindow(您的窗口)

另外,在创建新窗口时,在构造函数中传递指向navigationWindow的指针,然后可以正确关闭窗口。不要创建这样的窗口使用CommonJS的require()返回窗口:

paymenttransaction.js:

function paymentTransactionWindow(navGroup, otherArgs) { 

var mainWinClose = Ti.UI.createButton({
    style : Ti.UI.iPhone.SystemButtonStyle.DONE,
    title : 'close'
});

var win = Ti.UI.createWindow({
    url : url,
    backgroundColor : 'white',
    modal : true,
    title : title,
    rightNavButton: mainWinClose
});



if (Titanium.Platform.osname !== "android") {
    mainWinClose.addEventListener('click', function() {
    navGroup.closeWindow(win);
});

    return win;

}

module.exports = paymentTransactionWindow;
然后在您以前的窗口中:

PaymentTransactionWindow = require('/paymentTransactionWindow); //the filename minus .js
var paymentTransactionWindow = new PaymentTransactionWindow(winNav, null);
mainNav.openWindow(paymentTransactionWindow);

也可以在commonJS上观看一些视频:

。。3.1.3可能仍然使用:mainNav.open(yourWindow)和.close(),在3.X中,它现在是navigationWindow()而不是navigationGroup()。。我必须为这次API更改找到/替换我的整个代码库。