我在导航中添加了导航按钮,并在其上编写了“点击”功能,但第一次它不起作用。实际上,我在第一次单击时向导航栏添加按钮,但在第二次单击时不起作用,它起作用了,我该如何解决这个问题
我的xml代码是
<Alloy>
<Window id="aboutWin" name="aboutWinName">
<NavigationGroup id="navAbout" platform="ios">
<Window class="container" id="aboutChildWin">
<View id="aboutView">
<ImageView id="logoImg"></ImageView>
<ImageView id='logoWrd'></ImageView>
<Label id="versionLbl"></Label>
</View>
<View id="footView"></View>
</Window>
</NavigationGroup>
</Window>
</Alloy>
我的Js代码是
var button = Titanium.UI.createButton({
// title:"Back",
backgroundImage:"/images/MenuList.png",
// top : 4.5,
height : 35,
width : 40,
// left : 4
})
$.aboutChildWin.leftNavButton = button;
button.addEventListener('click',function(){
if(Ti.App.currentAnimateWindow == "About")
{
Ti.App.socialWindow.hide();
Ti.App.menuWindow.show();
$.aboutWin.animate(animateLeft);
Ti.App.currentAnimateWindow = "Menu";
}
else if(Ti.App.currentAnimateWindow == "Menu")
{
$.aboutWin.animate(animateRight);
Ti.App.currentAnimateWindow = "About";
}
})
谁能解决这个问题
最佳答案
我只是做了一些小改动,将添加按钮插入到导航窗口中,我将导航按钮添加到整个窗口。
代码是:
$.aboutWin.leftNavButton = button;
关于iphone - 添加导航按钮在钛合金中第一次不起作用,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/14929932/