钛合金 - 关闭窗口

时间:2013-12-12 07:27:16

标签: titanium titanium-alloy

我在Titanium Alloy工作并创建一个弹出窗口作为小部件。我希望将近距离图像放在右上角,因此它会从弹出窗口中退出。 所以我在widget xml文件中创建了2个单独的窗口。一个只是握住近景图像,一个是弹出窗口 Everythings看起来像我想要的,但我不能让弹出窗口关闭?!

我试过了: $ .myWindow.close();

Amd我试过了: var win = Widget.createController('myWindow','myWindowID')。getView(); win.close();

但没有任何反应

这是我的xml代码:

<Alloy>
    <Window id="popup">
        <View id="myImagesViewIn" class="myImagesViewIn" onClick="closeWin">
            <ImageView id="myImageIn" class="myImageIN" />
        </View>
    </Window>
    <Window id="winImageOut" onClick="closeWindow">
        <View id="myImagesViewOut" class="myImagesViewOut" >
            <ImageView id="myImageOut" class="myImageOut" />
        </View>
    </Window>
</Alloy>

这是我的JS代码:

var args = arguments[0] || {};

$.popup.transform = args.transform || '';

/*
 exports.setDataModalWindow = function(data) {
 $.lblModalWinHead.text = data.title;
 $.lblModalWinBody.text = data.text;
 };
 */
function fnCloseClick() {
    $.viewModal.close();
}

/*
 $.myImagesViewOut.addEventListener('click', function(e) {
 $.popup.close();
 });
 */

function closeWin(e) {
    $.myImagesViewOut.setVisible(false);
    $.popup.close();

}

function closeWindow(e) {

    //$.popup.close();
    var wins = Widget.createController('widget', 'popup').getView();
    wins.setVisible(false);
    alert('hejsan');
    //Ti.API.info('close');
}

exports.openModalWindow = function(arg) {

    //$.lblModalTitle.text = arg.title || 'foo';
    //$.lblModalText.text = arg.text || 'ff';

    var t = Titanium.UI.create2DMatrix().scale(0);

    var args = {

        transform : t
    };

    var controller = Widget.createController('widget', args).getView();

    controller.open();

    // controller.animate(a2);

    var t1 = Titanium.UI.create2DMatrix();
    t1 = t1.scale(1.2);
    var a1 = Titanium.UI.createAnimation();
    a1.transform = t1;
    a1.duration = 400;

    controller.animate(a1);

    var b1 = Titanium.UI.create2DMatrix();
    var a2;
    a1.addEventListener('complete', function() {
        b1 = b1.scale(1.5);
        a2 = Titanium.UI.createAnimation();
        a2.transform = b1;
        a2.duration = 400;

        controller.animate(a2);

    });
    // create the controller a keep the reference

    /*
    controller.setDetails({
    label: 'Are you sure you wish to log out?\n\nIf you do so you will no longer be able to take part in any challenges until you login again.',
    ok: 'Log me out',
    cancel: 'Cancel'
    });
    */
    // now get a reference to the UI inside the controller
    //var win = controller.getView();

    a1.addEventListener('complete', function() {
        // simple reset animation
        var t2 = Ti.UI.create2DMatrix();
        var a3 = Titanium.UI.createAnimation();
        a3.transform = t2;
        a3.duration = 400;
        controller.animate(a3);

        $.winImageOut.open();

    });

};

1 个答案:

答案 0 :(得分:1)

首先是你打开弹出窗口,所以你应该打开那个窗口......

然后你应该在closeWindow函数中关闭窗口。

function closeWindow(e) {

    $.popup.close();
    $.winImageOut.close();
    alert('hejsan');
    //Ti.API.info('close');
}

我不知道您的要求,但您应该只使用一个窗口来显示弹出窗口,然后您可以轻松处理窗口的打开,关闭事件。