钛合金LeftNavButton没有出现在模拟器中

时间:2014-03-16 00:25:14

标签: titanium titanium-alloy

不确定我在哪里做错了。我尝试通过代码和xml,但由于某种原因左侧导航按钮没有显示。我正在使用模拟器,因为我没有ios的实际设备。

xml视图

<!--filename: playType.xml->
<Alloy>
    <Window class="container">
        <LeftNavButton platform="ios">
            <Button title="Back" onClick="closeWindow"/>    
        </LeftNavButton>
        <View class="buttonContainer">
            <Button class="menuButton" title="Single Player"/>
            <Button class="menuButton" title ="Duel"/>
        </View>
    </Window>
</Alloy>

控制器

//playType.js
var args = arguments[0] || {};

var closeWindow = function(){
    $.playType.close();
};

tss风格

//playType.tss
".container" : {
  backgroundColor:"white",
  height:Ti.UI.FILL,
},
".buttonContainer":{
    center:{x:"50%",y:"50%"},
    height:Ti.UI.SIZE,
    layout:"vertical"   
}

我在index.js

中使用它
var playType = Alloy.createController('playType').getView();
playType.open();

窗口显示正常,中间有两个按钮,但后退按钮不显示。 我究竟做错了什么。我浏览了文档,也尝试了代码方式。结果相同,没有后退按钮。 :(

2 个答案:

答案 0 :(得分:1)

你必须使用导航窗口创建窗口,否则navButton不会显示出来。那里有代码链接

http://docs.appcelerator.com/titanium/3.0/#!/api/Titanium.UI.iOS.NavigationWindow

由于

答案 1 :(得分:0)

您的窗口必须放在TabGroup内,该{{3}}处理每个标签内导航控制器的所有功能。

<Alloy>
    <TabGroup>
        <Tab id="tab1" title="Tab 1">
            <Window id="win1" title="Tab 1">
                <LeftNavButton platform="ios">
                   <Button title="Back" onClick="closeWindow"/>    
                </LeftNavButton>
               ...
            </Window>
        </Tab>
    </TabGroup>
</Alloy>

对于后退按钮,使用选项卡作为open方法的参考,打开当前选项卡的子窗口。

tab.open(newWindow);
相关问题