目前正在努力让我的应用程序的代码在 Android 上达到里程碑后在 iOS 端运行。我有一个标签组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>
它是控制器index.js
:
/**
* The scoped constructor of the controller.
**/
(function constructor() {
//Alloy.CFG.tabGroup = index.getView('tabMenu');
globalTabGroup = $.tabMenu;
$.tabMenu.open();
})();
当单击按钮时,我正在尝试向搜索选项卡的导航堆栈添加一个视图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();
}
}
我尝试了几种不同的方法来尝试获取对活动选项卡的引用,以便我可以调用该选项卡的open()
函数并在搜索选项卡导航堆栈中添加下一个视图。然而,无论我如何尝试,我都会得到这个神秘、模糊的错误。
[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] : }
通过研究,我发现 NSCFString 是 NSString 的包装器,并且 isSetManaged 是布尔类型的变量(?),它在某处获取字符串(?)。我一点也不知道 Obj-C,所以这都是我对错误实际含义的推断。