Search code examples
titaniumtitanium-mobileappceleratortitanium-alloyappcelerator-mobile

In Titanium JS, when setting rightNavButtons, the buttons only work for the first 4 taps


In my app for iOS I've used the rightNavButtons property of a window to add two buttons in the top right.

However, the click events on these buttons only work for the first 4 taps and then nothing happens when you click on them. What is going on? Could this be a bug with Titanium?

Here is my code:

Titanium SDK version: 3.4.0.v20140916181713

Alloy version: 1.5.1

Controller - index.js:

var addButton = Ti.UI.createButton({ systemButton: Ti.UI.iPhone.SystemButton.ADD });
var searchButton = Ti.UI.createButton({ systemButton: Ti.UI.iPhone.SystemButton.SEARCH });

addButton.addEventListener("click", function () {
    console.log("ADD was clicked!");
});

searchButton.addEventListener("click", function () {
    console.log("SEARCH was clicked!");
});

$.win.setRightNavButtons([searchButton, addButton]);

$.index.open();

View - index.xml

<Alloy>
    <TabGroup>
        <Tab title="Tab 1" icon="KS_nav_ui.png">
            <Window id="win" title="Tab 1">
                <Label>I am Window 1</Label>
            </Window>
        </Tab>
        <Tab title="Tab 2" icon="KS_nav_views.png">
            <Window title="Tab 2">
                <Label>I am Window 2</Label>
            </Window>
        </Tab>
    </TabGroup>
</Alloy>

Solution

  • Tested this code and it should work for you

      <Tab title="Tab 1" icon="KS_nav_ui.png">
            <Window id="win" title="Tab 1">
               <RightNavButtons platform=ios>
                 <Button systemButton="Ti.UI.iPhone.SystemButton.ADD" onClick="addHandler" />
                 <Button systemButton="Ti.UI.iPhone.SystemButton.SEARCH" onClick="searchHandler" />
               </RightNavButtons>
               <Label>I am Window 1</Label>
            </Window>
        </Tab>