[TIMOB-709] size.height and size.width properties are 0 when height or width auto is used
GitHub Issue | n/a |
---|---|
Type | Bug |
Priority | Medium |
Status | Closed |
Resolution | Fixed |
Resolution Date | 2011-04-17T01:53:59.000+0000 |
Affected Version/s | n/a |
Fix Version/s | Release 1.3.0 |
Components | iOS |
Labels | n/a |
Reporter | Nolan Wright |
Assignee | Blain Hamon |
Created | 2011-04-15T02:34:56.000+0000 |
Updated | 2011-04-17T01:53:59.000+0000 |
Description
from premium support:
http://helpdesk.appcelerator.net/tickets/1762">http://helpdesk.appcelerator.net/tickets/1762
Comments
- Stephen Tramer 2011-04-15
Partial fix for this that solves the user's problem:
You can't get these values before the window is drawn, because the autosize values are not computed until that time. So what you can do is:
var realWidth = null; var realHeight = null; win.addEventListener('open', function(e) { realWidth = view.size.width; realHeight = view.size.height; });
Blain says this might not work for tableRowViews, however, since they are lazyload. This should solve the customer's problem however.
Leaving the bug open until we can come up with a tableRowView solution.
- Stephen Tramer 2011-04-15
Closing this, it's just not possible to get useful size information without drawing all superviews (which, in the case of an element like a label, means drawing everything). The user can get the desired behavior by using code like the following:
var label1 = Ti.UI.createLabel({ text: 'Some Name', color: 'blue', font: { fontSize: 16}, width: 'auto', height: 'auto', bottom:0, left:0 }); win.add(label1); var label2 = Ti.UI.createLabel({ text: 'says', font: {fontStyle: 'italic', fontSize: 16}, color:'black', width: 'auto', height: 'auto', bottom:0 }); win.add(label2); win.addEventListener('open', function(e) { label2.left = label1.size.width+20; });
Positioning elements based on other autosize elements has to be done on window open (and yes, they are redrawn correctly before display). Handling table rows is all done internally and the user should have no control over it. Create another bug if that becomes an issue.