[TIMOB-15692] TiAPI: removeAllChildren method for view
GitHub Issue | n/a |
---|---|
Type | New Feature |
Priority | n/a |
Status | Closed |
Resolution | Fixed |
Resolution Date | 2012-09-21T13:46:15.000+0000 |
Affected Version/s | n/a |
Fix Version/s | Release 3.1.0 |
Components | Android, iOS |
Labels | android, ios, module_views, qe-closed-3.2.0, qe-testadded, remove, view |
Reporter | Martin Guillon |
Assignee | Sabil Rahim |
Created | 2012-08-21T00:46:39.000+0000 |
Updated | 2014-01-23T10:38:25.000+0000 |
Description
It can be very useful to have a safe method to remove all children from a view.
test case
var win = Ti.UI.createWindow({ backgroundColor: '#fff' });
var scrollView = Ti.UI.createScrollView({height:200,top:0});
win.add(scrollView);
var view1 = Ti.UI.createView({
backgroundColor:'pink',
zIndex:10,
width:200,
height:30,
top:10,
left:10
});
var view2 = Ti.UI.createView({
backgroundColor:'blue',
zIndex:11,
width:200,
height:30,
top:15,
left:15
});
var view3 = Ti.UI.createView({
backgroundColor:'red',
zIndex:12,
width:200,
height:30,
top:20,
left:20
});
scrollView.add(view3);
scrollView.add(view2);
scrollView.add(view1);
var l = Ti.UI.createLabel({
text:'scroll view: red on top, blue in the middle, pink below',
color:'#777',
width:300,
height:20,
top:50,
left:10,
font:{fontSize:12}
});
scrollView.add(l);
var buttonAdd = Ti.UI.createButton({
title: 'Add',
top: 10,
width: 200,
height: 30
});
buttonAdd.addEventListener('click', function(){
scrollView.add(view3);
scrollView.add(view2);
scrollView.add(view1);
scrollView.add(l);
});
win.add(buttonAdd);
var buttonRemove = Ti.UI.createButton({
title: 'RemoveAll',
bottom: 10,
width: 200,
height: 30
});
buttonRemove.addEventListener('click', function(){
scrollView.removeAllChildren();
});
win.add(buttonRemove);
win.open();
pull request https://github.com/appcelerator/titanium_mobile/pull/2788
Pull request needs to be merged
PR submitted
removeAllChildren method working fine... Hence verified and closed. Appc-Studio: 3.2.0.201312191455 Sdk:3.2.0.GA acs:1.0.11 alloy:1.3.1-beta npm:1.3.2 titanium:3.2.0 titanium-code-processor:1.1.0 Osx: Maverick 10.9 Xcode: xCode 5.0.2 Device: HTC Desire(v4.0.3) and iPHONE Simulator(v7.0.3)