1
votes

I've implemented the hidden search bar for iOS using the Titanium Alloy framework, using the searchHidden property on a TableView.

It works well at first, the search bar is hidden... But when the user taps on a menu item and opens a new window, it causes the search bar to appear suddenly as the new window is animating into view. And then when the user goes back to the original window with the TableView (by tapping Back), the search bar is there, when it should be hidden.

Here is my view:

<Alloy>
    <NavigationWindow id="navWin">
        <Window class="container">
            <TableView onClick="doClick" id="theTable" searchHidden="true">
                <SearchBar></SearchBar>
                <TableViewRow title="Item One"></TableViewRow>
                <TableViewRow title="Item Two"></TableViewRow>
                <TableViewRow title="Item Three"></TableViewRow>
                <TableViewRow title="Item Four"></TableViewRow>
                <TableViewRow title="Item Five"></TableViewRow>
                <TableViewRow title="Item Six"></TableViewRow>
                <TableViewRow title="Item Seven"></TableViewRow>
                <TableViewRow title="Item Eight"></TableViewRow>
                <TableViewRow title="Item Nine"></TableViewRow>
            </TableView>
        </Window>
    </NavigationWindow>
</Alloy>

And here is my controller:

function doClick() {
   var win = Ti.UI.createWindow({
       title: "Window",
       backgroundColor: "#FFF"
   });
   $.navWin.openWindow(win, {animated: true}); 
};

$.navWin.open();
1

1 Answers

1
votes

Yes, i also face the same Situation, one of the solutions can be setting the setSearchHidden Method to be called onFocus of the window, Something like :

$.mainwin.addEventListener("focus",function(){
    $.theTable.setSearchHidden(true);
});

considering mainwin is the id of Window here.

UPDATE

okay, i have one more solution but it will need changes in your Event Listener.

you have to add a view inside each tableViewRow and have to set bubbleParent as false for the view, and the eventlistener to open another window has to be added to the newly added View, then your Searchbar will not come into play.

Something like :

<TableViewRow title="Item One" bubbleParent="false" >
     <View bubbleParent="false" onClick="doClick"></View>
</TableViewRow>

As update 1 did not worked with more than one row so here is UPDATE 2

Add the following on focus, and don't forget to hide the search on opening the window.

$.mainwin.addEventListener("focus",function(){
    $.theTable.setSearchHidden(true);

    setTimeout(function(){
        $.search.show();
    },1000);

});

Although it also gives a little jerk but the search is hidden.