나는 티타늄에서 뷰를 전환하는 방법을 알아낼 수 없습니다.티타늄으로 전환하는 올바른 방법은 무엇입니까?
두 파일에서 두 가지보기가 있습니다 (아마도 다른 창을 사용해야합니까?).
ApplicationWindow.js
//Application Window Component Constructor
function ApplicationWindow() {
//load component dependencies
var FirstView = require('ui/common/FirstView');
//create component instance
var self = Ti.UI.createWindow({
backgroundColor:'#ffffff'
});
//construct UI
var firstView = new FirstView();
self.add(firstView);
return self;
}
FirstView.js
//FirstView Component Constructor
function FirstView() {
//create object instance, a parasitic subclass of Observable
var self = Ti.UI.createView();
var create_button = Ti.UI.createButton({
title: L('create_game'),
height:'auto',
width:200,
top:40,
borderWidth:1
});
self.add(create_button);
var join_button = Ti.UI.createButton({
title: L('join_game'),
height:'auto',
width:200,
top:80,
borderWidth:1
});
self.add(join_button);
var anim;
create_button.addEventListener('click', function(e) {
var CreateGameView = require('ui/common/CreateGameView');
var createGameView = new CreateGameView();
createGameView.setLeft(640);
self.parent.add(createGameView);
anim = Ti.UI.createAnimation({
left: -640,
duration: 1000
});
self.animate(anim, function() {
anim = Ti.UI.createAnimation({
left: 0,
duration: 1000
});
createGameView.animate(anim);
});
});
join_button.addEventListener('click', function(e) {
alert(e.source.text);
});
return self;
}
module.exports = FirstView;
CreateGameView.js
//CreateGameView Component Constructor
function CreateGameView() {
//create object instance, a parasitic subclass of Observable
var self = Ti.UI.createView();
var start_button = Ti.UI.createButton({
title: 'Pickles',
height:'auto',
width:200,
top:40,
borderWidth:1
});
self.add(start_button);
var join_button = Ti.UI.createButton({
title: L('join_game'),
height:'auto',
width:200,
top:80,
borderWidth:1
});
// Add behavior for UI
join_button.addEventListener('click', function(e) {
alert(e.source.text);
});
return self;
}
module.exports = CreateGameView;
이 코드는 정말 작동하지 않습니다.
도움?
무엇이 잘못되었는지 설명 할 수 있습니까? –
@pronox 시도해 볼 수 있습니다. 두 번째보기는 애니메이션 이후에 표시되지 않습니다. 수동으로 왼쪽 0으로 설정하면 작동하지만 애니메이션 없음. – user3498345