使用后退按钮导航时,TitaniumImageImage会从左侧跳转

时间:2014-05-16 14:46:58

标签: ios titanium titanium-mobile appcelerator titanium-alloy

我在Windows上使用titleImage在Appcelerator Titanium中遇到问题。当一个新窗口打开时,titleImage会向左设置动画,并在您期望它时淡化。但是当你使用后退按钮时,titlImage突然出现在左侧并动画回到中心,没有褪色。它看起来非常生涩和破碎。

以下是我的代码,请参阅下面的问题截图:

查看

<TabGroup id="tabGroup">
    <Tab id="tab1" title="Tab 1">
        <Window id="win" title="Tab 1" titleImage="title-brand.png">
            <Button onClick="openWindow">I am Window 1</Button>
        </Window>
    </Tab>
    <Tab title="Tab 2">
        <Window title="Tab 2">
            <Label>I am Window 2</Label>
        </Window>
    </Tab>
</TabGroup>

控制器JS

function openWindow() {
    var window2 = Ti.UI.createWindow({ title: "Window 2" });
    var label = Ti.UI.createLabel({ text: "Hello!" });
    window2.add(label);
    $.tab1.open(window2, { animated: true });
}

$.tabGroup.open();

Screnshot

正如您在此屏幕截图中看到的那样,当点击后退按钮时,Window 1会动画,但titleImage出现在左侧,然后跳转到中心:

enter image description here

2 个答案:

答案 0 :(得分:2)

这是Titanium Mobile中的一个错误,已在版本3.3.0中修复,计划于2014年6月23日发布。错误报告为here.

答案 1 :(得分:2)

尝试设置titleControl而不是titleImage。这是解决这个问题的方法。

<强> .XML

<TabGroup id="tabGroup">
    <Tab id="tab1" title="Tab 1">
        <Window id="win" title="Tab 1" titleImage="title-brand.png">
            <Button onClick="openWindow">I am Window 1</Button>
        </Window>
    </Tab>
    <Tab title="Tab 2">
        <Window title="Tab 2">
            <Label>I am Window 2</Label>
        </Window>
    </Tab>
</TabGroup>

<强>的.js

var imageView = Ti.UI.createImageView({
    image : "KS_nav_views.png",
    width : Ti.UI.SIZE,
    height : Ti.UI.SIZE
});
$.win.titleControl = imageView;

function openWindow() {
    var window2 = Ti.UI.createWindow({
        title : "Window 2"
    });
    var label = Ti.UI.createLabel({
        text : "Hello!"
    });
    window2.add(label);
    $.tab1.open(window2, {
        animated : true
    });
}

$.tabGroup.open();