Currently working on getting the code for my app to run on the iOS side after hitting a milestone on Android. I have a tabgroup in my index.xml
:
<Alloy>
<TabGroup id="tabMenu" title="USHUD | Home" tabsBackgroundColor="Alloy.CFG.design.colors.hudGrey" tabsBackgroundSelectedColor="Alloy.CFG.design.colors.hudBlue">
// ------------------------------------ SEARCH TAB --------------------------------------------------
<Require src="search_tab/search"/>
// ------------------------------------ FAVORITES TAB --------------------------------------------------
<Require src="favorites"/>
// ------------------------------------ ABOUT TAB ---------------------------------------------------
<Require src="about"/>
</TabGroup>
</Alloy>
and it's controller index.js
:
/**
* The scoped constructor of the controller.
**/
(function constructor() {
//Alloy.CFG.tabGroup = index.getView('tabMenu');
globalTabGroup = $.tabMenu;
$.tabMenu.open();
})();
I'm trying to add a view to the search tab's navigation stack when the button gets clicked in search_tab/search.xml
:
<Alloy>
<Tab id='searchTab' class="homeTab" title="Search" icon='/images/search-1.png'>
<Window id="searchWin" title="Property Search">
<View class="vgroup" id="wrapper">
<ImageView height="Titanium.UI.SIZE" left="20" id="hud_logo" image="/images/US.png"/>
<Button class="button-default bottom" id="buttonSearch" onClick="startSearch" title="Begin Search" zIndex="1"/>
</View>
</Window>
</Tab>
search_tab/search.js
:
// Arguments passed into this controller can be accessed via the $.args object directly or:
var args = $.args;
function startSearch(e){
if(OS_ANDROID){
Alloy.createController("search_tab/states").getView().open();
}else if(OS_IOS){
//Ti.API.debug('Current Window: '+Ti.UI.currentWindow);
//Ti.API.debug('Current Tab: '+Ti.UI.currentTab);
//Ti.UI.currentTab.open('search_tab/states');
globalTabGroup.activeTab.open('search_tab/states');
//$.searchTab.open('search_tab/states');
//Alloy.Globals.tabGroup.activeTab.open('search_tab/states');
//Alloy.createController("search_tab/states").getView().open();
}
}
I have tried a few different approaches trying to get a reference to the active tab so that I can call that tab's open()
function and add the next view in the search tab navigation stack. However, no matter how I try it I get this cryptic, vague error.
[ERROR] : Script Error {
[ERROR] : column = 332;
[ERROR] : line = 1;
[ERROR] : message = "-[__NSCFString setIsManaged:]: unrecognized selector sent to instance 0x15e61000";
[ERROR] : sourceURL = "file:///private/var/mobile/Containers/Bundle/Application/7D2E0E41-E28B-40F8-90D1-485279A0B8F6/USHUD.app/alloy/controllers/search_tab/search.js";
[ERROR] : stack = "[native code]\ne@file:///private/var/mobile/Containers/Bundle/Application/7D2E0E41-E28B-40F8-90D1-485279A0B8F6/USHUD.app/alloy/controllers/search_tab/search.js:1:332";
[ERROR] : }
Through research I found that the NSCFString is a wrapper for NSString and that isSetManaged is a variable of boolean type(?) that is getting a string somewhere(?). I don't know a lick of Obj-C so this is all inference on my end as to what the error actually means.
In iOS, you are passing a string to activeTab.open() method, not a window controller. But in android you are creating a controller and then you are calling open method of controller which works correctly.
So this code will definitely work for you:
index.js
/**
* The scoped constructor of the controller.
**/
(function constructor() {
Alloy.Globals.globalTabGroup = $.tabMenu;
$.tabMenu.open();
})();
search_tab/search.js:
// Arguments passed into this controller can be accessed via the $.args object directly or:
var args = $.args;
function startSearch(e){
var statesWin = Alloy.createController("search_tab/states").getView();
OS_IOS ? Alloy.Globals.globalTabGroup.activeTab.open(statesWin) : statesWin.open();
}