[TIMOB-10039] iOS: Label does not show in nested views
| GitHub Issue | n/a |
|---|---|
| Type | Bug |
| Priority | High |
| Status | Closed |
| Resolution | Fixed |
| Resolution Date | 2012-08-09T03:37:07.000+0000 |
| Affected Version/s | Release 3.0.0 |
| Fix Version/s | Sprint 2012-15 API, Release 3.0.0 |
| Components | iOS |
| Labels | api, module_view, qe-testadded, regression |
| Reporter | Allen Yeung |
| Assignee | Vishal Duggal |
| Created | 2012-07-19T11:52:18.000+0000 |
| Updated | 2014-06-19T12:44:14.000+0000 |
Description
Run the following code:
var win = Ti.UI.createWindow({
navBarHidden : true,
backgroundColor : 'white'
});
var parentView = Ti.UI.createView({
backgroundColor : 'blue',
width : Ti.UI.FILL,
height : Ti.UI.SIZE,
});
function createContent() {
var view = Ti.UI.createView({
top : 0,
layout : 'horizontal',
width : Ti.UI.FILL,
height : Ti.UI.SIZE,
backgroundColor : 'red'
});
var header = Ti.UI.createView({
width : '90%',
height : '75dp',
backgroundColor : 'green'
});
var label = Ti.UI.createLabel({
top : 0,
height : '75dp',
width : '50%',
text : 'Testing ...'
});
var active = Ti.UI.createSwitch({
top : 0,
value:true
//style : Ti.UI.Android.SWITCH_STYLE_CHECKBOX
});
header.add(label);
header.add(active);
view.add(header);
return view;
}
for (var i = 0; i < 3; ++i) {
parentView.add(createContent());
}
win.add(parentView);
win.open();
Expected result:
The 'testing' label should show
Actual result:
The 'testing' label does not show up
Note: This only happens on master and is not a regression on 2_1_X. After running a git bisect, it looks like it's caused by this commit: https://github.com/appcelerator/titanium_mobile/commit/00e3d138d63902fad810c4cb7e55352ce33b8c6e
Test Case from TIMOB-2574
var win = Ti.UI.createWindow({ backgroundColor: 'white', }); var theFont = {fontSize: 11, font: 'Helevetica' }; var container = Ti.UI.createView({ layout:'vertical' }) var controls1 = Ti.UI.createView({ layout:'horizontal', height:Ti.UI.SIZE, top:10, borderColor:'#ccc', borderWidth:1 }) var title1 = Ti.UI.createLabel({ font :theFont, text:'V-ALIGN' }) var c1b1 = Ti.UI.createButton({ left:10, font :theFont, title:'TOP' }) var c1b2 = Ti.UI.createButton({ left:10, font :theFont, title:'BOTTOM' }) var c1b3 = Ti.UI.createButton({ left:10, font :theFont, title:'CENTER' }) controls1.add(title1); controls1.add(c1b1); controls1.add(c1b2); controls1.add(c1b3); container.add(controls1) var controls2 = Ti.UI.createView({ layout:'horizontal', height:Ti.UI.SIZE, top:10, borderColor:'#ccc', borderWidth:1 }) var title2 = Ti.UI.createLabel({ font :theFont, text:'T-ALIGN' }) var c2b1 = Ti.UI.createButton({ left:10, font :theFont, title:'LEFT' }) var c2b2 = Ti.UI.createButton({ left:10, font :theFont, title:'RIGHT' }) var c2b3 = Ti.UI.createButton({ left:10, font :theFont, title:'CENTER' }) controls2.add(title2); controls2.add(c2b1); controls2.add(c2b2); controls2.add(c2b3); container.add(controls2) var controls3 = Ti.UI.createView({ layout:'horizontal', height:Ti.UI.SIZE, top:10, borderColor:'#ccc', borderWidth:1 }) var title3 = Ti.UI.createLabel({ font :theFont, text:'WIDTH' }) var c3b1 = Ti.UI.createButton({ left:10, font :theFont, title:'SIZE' }) var c3b2 = Ti.UI.createButton({ left:10, font :theFont, title:'200' }) var c3b3 = Ti.UI.createButton({ left:10, font :theFont, title:'150' }) var c3b4 = Ti.UI.createButton({ left:10, font :theFont, title:'100' }) controls3.add(title3); controls3.add(c3b1); controls3.add(c3b2); controls3.add(c3b3); controls3.add(c3b4); container.add(controls3); var controls4 = Ti.UI.createView({ layout:'horizontal', height:Ti.UI.SIZE, top:10, borderColor:'#ccc', borderWidth:1 }) var title4 = Ti.UI.createLabel({ font :theFont, text:'HEIGHT' }) var c4b1 = Ti.UI.createButton({ left:10, font :theFont, title:'SIZE' }) var c4b2 = Ti.UI.createButton({ left:10, font :theFont, title:'200' }) var c4b3 = Ti.UI.createButton({ left:10, font :theFont, title:'150' }) var c4b4 = Ti.UI.createButton({ left:10, font :theFont, title:'100' }) controls4.add(title4); controls4.add(c4b1); controls4.add(c4b2); controls4.add(c4b3); controls4.add(c4b4); container.add(controls4); var controls5 = Ti.UI.createView({ layout:'horizontal', height:Ti.UI.SIZE, top:10, borderColor:'#ccc', borderWidth:1 }) var title5 = Ti.UI.createLabel({ font :theFont, text:'TEXT' }) var c5b1 = Ti.UI.createButton({ left:10, font :theFont, title:'TEXT 1' }) var c5b2 = Ti.UI.createButton({ left:10, font :theFont, title:'TEXT 2' }) var c5b3 = Ti.UI.createButton({ left:10, font :theFont, title:'TEXT 3' }) controls5.add(title5); controls5.add(c5b1); controls5.add(c5b2); controls5.add(c5b3); container.add(controls5); var text1 = 'I am the test label. Switch my properties around and see me change. Vertical Alignment should work well with change in size and text alignment.'; var text2 = 'I am a medium size label that should span more than one line.' var text3 = 'Short Label.' var testLabel = Ti.UI.createLabel({ backgroundColor: 'white', color: 'black', text:text1, borderColor:'red', borderWidth:1, top:10 }) container.add(testLabel); win.add(container); win.open(); c1b1.addEventListener('click',function(e){testLabel.verticalAlign = Ti.UI.TEXT_VERTICAL_ALIGNMENT_TOP}); c1b2.addEventListener('click',function(e){testLabel.verticalAlign = Ti.UI.TEXT_VERTICAL_ALIGNMENT_BOTTOM}); c1b3.addEventListener('click',function(e){testLabel.verticalAlign = Ti.UI.TEXT_VERTICAL_ALIGNMENT_CENTER}); c2b1.addEventListener('click',function(e){testLabel.textAlign = Ti.UI.TEXT_ALIGNMENT_LEFT}); c2b2.addEventListener('click',function(e){testLabel.textAlign = Ti.UI.TEXT_ALIGNMENT_RIGHT}); c2b3.addEventListener('click',function(e){testLabel.textAlign = Ti.UI.TEXT_ALIGNMENT_CENTER}); c3b1.addEventListener('click',function(e){testLabel.width = Ti.UI.SIZE}) c3b2.addEventListener('click',function(e){testLabel.width = 200}) c3b3.addEventListener('click',function(e){testLabel.width = 150}) c3b4.addEventListener('click',function(e){testLabel.width = 100}) c4b1.addEventListener('click',function(e){testLabel.height = Ti.UI.SIZE}) c4b2.addEventListener('click',function(e){testLabel.height = 200}) c4b3.addEventListener('click',function(e){testLabel.height = 150}) c4b4.addEventListener('click',function(e){testLabel.height = 100}) c5b1.addEventListener('click',function(e){testLabel.text = text1}) c5b2.addEventListener('click',function(e){testLabel.text = text2}) c5b3.addEventListener('click',function(e){testLabel.text = text3})Pull pending https://github.com/appcelerator/titanium_mobile/pull/2620
reopening to update labels