【问题标题】:Titanium Alloy - Closeing window钛合金 - 关闭窗口
【发布时间】:2013-12-12 07:27:15
【问题描述】:

我正在使用钛合金并创建一个弹出窗口作为小部件。我想在右上角有近距离图像,所以它会从弹出窗口中伸出。 所以我在小部件 xml 文件中创建了 2 个单独的窗口。一个只按住关闭图像,另一个是弹出窗口。
一切看起来都如我所愿,但我无法关闭弹出窗口?!

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

我已经尝试过: 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();

    });

};

【问题讨论】:

    标签: titanium titanium-alloy


    【解决方案1】:

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

    那么你应该在 closeWindow 函数中关闭机器人窗口。

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

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

    【讨论】:

    • 感谢您的回复!问题是我有一个单独的窗口中的关闭按钮,因为我想让关闭图片贴在弹出窗口角落之外一点。 sims 在单独的窗口中设置关闭图片的唯一方法,否则当我在 px 中使用减号时,图片会在窗口角落下方。当我点击关闭时,现在唯一发生的事情就是关闭图片,换句话说,关闭图片所在的另一个窗口。
    • 那么您应该打开一个具有屏幕高度和宽度的窗口,然后您可以使用视图来显示弹出内容,以便您可以在弹出视图之外的窗口中添加关闭按钮
    • 是的,然后我可以设置该窗口完全透明,就像你说的那样,我在其中使用视图。但是打开/显示过程中的动画怎么样?我可以将动画作为参数放在视图的显示功能中吗?因为我想从无到有打开 Window / View 以缩放 1.2 并恢复到它的大小?!
    • 我的解决方案是什么时候仍然在透明窗口上有打开动画,并在视图角之外包含背景和关闭图像的视图(小一点)。非常感谢您的帮助!
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2013-10-11
    • 1970-01-01
    • 1970-01-01
    • 2016-10-11
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多