目前正致力於在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