hello ~ i have some question want to ask. how to remove firstView and read children length ,getChildren. I use this construction to code. I have a window(mainWindow), view(mainView), view(firstView) I want to click my button can execute remove all elements on firstView(firstView have to removed,too). the button is on the firstView, but I can't remove firstView and not read children length,getChildren on the firstView. hot to fix can remove firstView and read children on the firstView. thank you very much. this is my code.
-------------app.js--------------
var GVal = new (require('GVal'))(); var appWin = require('ui').Mainwin(GVal);
GVal.MainView.add(require('ui').firstView(GVal)); appWin.open();
Ti.App.addEventListener('clearFirstViewAddOtherView', function(e){
// can't read
Ti.API.info('CreateLoginView view :'+ require('ui').firstView.children.length );
Ti.API.info('CreateLoginView view :'+ require('ui').firstView.getChildren() );
// can't remove firstView ,why?
Val.MainView.remove(require('ui').firstView);
})
-----------app.js end----------
-------------GVal.js--------------
function GVal(){ this.MainView = undefined; this.firstView = undefined;
} module.exports = GVal;
------------GVal.js end----------
----------------ui.js------------------
function Mainwin(GVal){ var win = Ti.UI.createWindow( { title:'test', backgroundColor:'#fff', navBarHidden: true } );
var view = Ti.UI.createView(
{
height: 340,
width: 270,
left: 20 ,
top: 50,
backgroundColor: '#ccc',
borderWidth: 1
}
);
win.add(view);
GVal.MainView = view;
var label = Ti.UI.createLabel({
text: "Title Test" ,
top: 10 ,
width: view.width ,
height: 40 ,
backgroundColor: '#666',
textAlign: 'center' ,
font:{ fontSize:25, fontFamily: 'Helvetica Neue' }
});
view.add(label);
return win;
}; exports.Mainwin = Mainwin;
function firstView(GVal){ var view = Ti.UI.createView( { height: 200, width: 220,
left: 30,
top: 80,
backgroundColor: '#fff',
borderWidth: 1,borderRadius:7
}
);
var firstViewLabel = Ti.UI.createLabel(
{
text: "Here is first View" ,
top: 20 ,
width: 130 ,
height: 60 ,
backgroundColor: '#fff',
}
)
view.add(firstViewLabel);
var contentLabel = Ti.UI.createLabel(
{
text: "content label balbal" ,
top: 70 ,
width: 130 ,
height: 60 ,
backgroundColor: '#666',
}
)
view.add(contentLabel);
var clearBtn = Ti.UI.createButton(
{
width: 200, height: 20, left: 10, top: 150,
title:'clear first view and button'
}
)
view.add(clearBtn);
clearBtn.addEventListener('click', function(e){
Ti.App.fireEvent('clearFirstViewAddOtherView');
})
GVal.firstView = view;
return view;
}; exports.firstView = firstView;
------------ui.js end------------
1 Answer
who can help me? have any one know this problem? thank you very much.
Your Answer
This question has been locked and cannot accept new answers.