【Titaniumメモ】(002)TabGroupで子ウィンドウの子ウィンドウでメモしたことの改訂版。 なんか弄っていたら普通にTabGroupで親ウィンドウ→子ウィンドウ→子のウィンドウ遷移ができた。
1.親ウィンドウ
// 親ウィンドウ function ParentWindow(title) { var self = Ti.UI.createWindow({ title:title, backgroundColor:'white' }); var button = Ti.UI.createButton({ height:44, width:200, title:L('OpenChildWindow1'), top:20 }); self.add(button); // ChildWindowに遷移する。 // 画面遷移のアニメーションは右から左にWindowがスライドする。 button.addEventListener('click', function() { // 子ウィンドウ var wChildWindow = new ChildWindow(self); self.containingTab.open( wChildWindow,{anmated:true} ); }); return self; }; module.exports = ParentWindow;
2.子ウィンドウ
// 子ウィンドウ // 呼び出し元ウィンドウ(ParentWindow)を引数で受け取る function ChildWindow(ParentWindow) { var self = Ti.UI.createWindow({ title:"ChildWindow1", backgroundColor:'blue' }); var button = Ti.UI.createButton({ height:44, width:200, title:L('OpenChildWindow2'), top:20 }); self.add(button); // 子ウィンドウ2を表示 button.addEventListener('click', function() { // 子ウィンドウ2 var wChildWindow2 = new ChildWindow2(self); ParentWindow.containingTab.open( wChildWindow2,{anmated:true} ); }); return self; }; module.exports = ChildWindow;
3.子ウィンドウ2
// 子ウィンドウ2 // 呼び出し元ウィンドウ(ParentWindow)を引数で受け取る function ChildWindow2(ParentWindow) { var self = Ti.UI.createWindow({ title:"ChildWindow2", backgroundColor:'yellow' }); return self; }; module.exports = ChildWindow2;
ポイント: 各子ウィンドウを生成時に、呼び出し元ウィンドウ(self)を引数で渡す。
wChildWindow = new ChildWindow(self);
子ウィンドウ側で、さらに子ウィンドウ2に遷移する際は、 self.containingTab.openではなく、ParentWindow.containingTab.openで子ウィンドウ2を開く。
// 子ウィンドウ2 var wChildWindow2 = new ChildWindow2(self); ParentWindow.containingTab.open( wChildWindow2,{anmated:true} );
この方法であれば(いや、正しいのかは未だに分からず)、ナビゲーションバーのボタン形状(左側が三角)や 遷移のアニメーション(右から左にアニメーション)も問題なく動く。
コメント
by 【Titaniumメモ】(002)TabGroupで子ウィンドウの子ウィンドウささブログ « ささブログ 2013/04/26 11:19