bil*_*alq 2 javascript titanium appcelerator-mobile ios titanium-mobile
我正在尝试为窗口创建rightNavButton.
我视图中的代码如下所示:
<Alloy>
<Window title="TabName" id="myWindow">
<Label>Text</Label>
<Button id="topRight">Foo</Button>
</Window>
</Alloy>
Run Code Online (Sandbox Code Playgroud)
我试图找到一种方法来将窗口的rightNavButton设置为某种东西,并且认为在控制器中设置属性是可行的方法.我可以让一个按钮位于右上方,但它也将始终存在于窗口中.
$.myWindow.rightNavButton = $.topRight;
Run Code Online (Sandbox Code Playgroud)
我已经考虑为按钮创建一个单独的视图并以某种方式要求它,但我不知道该怎么做.我甚至不确定这是否是正确的做法.
任何帮助,将不胜感激!
编辑:
我现在有一个解决方法.
$.myWindow.rightNavButton = Ti.UI.createButton({title: 'topRight'});
Run Code Online (Sandbox Code Playgroud)
控制器中的代码可以工作,但它似乎打败了使用合金的全部要点.现在该按钮将不再存在于XML文件中.
看看我的项目https://github.com/aaronksaunders/alloy_fugitive
我将按钮添加到view.xml,然后将其设置在控制器中
$.fugitiveWindow.setRightNavButton($.add);
Run Code Online (Sandbox Code Playgroud)
在view.xml中
<Alloy>
<Tab id="fugitiveTab" title="Fugitives">
<Window id="fugitiveWindow" title="Fugitives" class='container'>
<TableView id="table"/>
<!-- hidden and used later -->
<Button id="add" title="Add" top="-50dp"></Button>
</Window>
</Tab>
</Alloy>
Run Code Online (Sandbox Code Playgroud)