【问题标题】:Titanium Alloy LeftNavButton not showing up in simulator钛合金 LeftNavButton 未出现在模拟器中
【发布时间】:2014-03-16 00:25:13
【问题描述】:

不知道我在哪里做错了。我尝试通过代码和 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();

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

【问题讨论】:

    标签: titanium titanium-alloy


    【解决方案1】:

    您必须使用导航窗口创建窗口,否则 navButton 不会显示。这里是您的代码链接

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

    谢谢

    【讨论】:

      【解决方案2】:

      您的窗口必须放在TabGroup 中,该TabGroup 处理每个选项卡内导航控制器的所有功能。

      <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>
      

      至于后退按钮,使用tab作为open方法的引用,打开当前tab的一个子窗口。

      tab.open(newWindow);
      

      【讨论】:

        猜你喜欢
        • 2016-12-01
        • 1970-01-01
        • 2020-10-29
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        相关资源
        最近更新 更多