目前正致力于在Android上达到里程碑后让我的应用程序的代码在iOS端运行。我在我的index.xml
一个tabgroup:Tabgroup iOS选项卡不会打开新视图,但会产生Obj-C错误
<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]\[email protected]:///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的一个舔,所以这是我的结论是什么错误实际上意味着什么。
自从改用这种方法每个窗口在Android端关闭退出。我为每个Android窗口设置了'exitOnClose'。对此行为有任何想法? – Rampancy
没关系,我发现在我的选项卡组中添加exitOnClose到我的根窗口中会去除应用中更深层窗口的其他部分。 – Rampancy