Titanium JIRA Archive
Titanium SDK/CLI (TIMOB)

[TIMOB-15938] iOS: Rect not reported when view has borders or have no borders

GitHub Issuen/a
TypeBug
PriorityHigh
StatusClosed
ResolutionWon't Fix
Resolution Date2013-12-10T18:32:32.000+0000
Affected Version/sRelease 3.2.0
Fix Version/sn/a
ComponentsiOS
Labelsqe-3.2.0
ReporterPriya Agarwal
AssigneeIngo Muschenetz
Created2013-12-10T11:39:47.000+0000
Updated2014-06-19T12:43:32.000+0000

Description

Rect not reported when view has borders or have no borders.
var win = Ti.UI.createWindow({
    backgroundColor:'white'
});
 
var cropRectView = Ti.UI.createView({
    width:200,
    height:300,
    left:100,
    top:60,
    backgroundColor:'#5500ff00',
    borderWidth:2,
    borderColor:'white'
});
 
 
cropRectView.addEventListener('postlayout', function(e){
    Ti.API.info('cropRectView postlayout ' + JSON.stringify(cropRectView.rect));
});
 
win.add(cropRectView);
 
win.open();
Steps to reproduce: 1)Copy paste the code in app.js and run the app. Observe the console Expected Result: cropRectView postlayout {"height":300,"y":60,"x":100,"width":200} Actual Result: cropRectView postlayout {} Works fine on android.

Comments

  1. Vishal Duggal 2013-12-10

    On iOS we return a TiRect object which is of type Proxy. Proxies by default are not seralizable so we return null on the toJSON call. So stringify will return nothing. The values x,y,width and height are still accessible though.
       var rect = cropRectView.rect;
       Ti.API.info(rect.x+' '+rect.y+' '+rect.width+' '+rect.height)
       
  2. Priya Agarwal 2013-12-11

    Tested Environment: Appcelerator Studio: 3.2.0.201312101708 SDK:3.2.0.v20131210191510 alloy: 1.3.0-cr acs: 1.0.10 npm: 1.3.2 titanium: 3.2.0-cr titanium-code-processor: 1.1.0-cr Xcode:5.0.2 OS: Mac OSX 10.9 Device: iPhone Simulator(v7.0.3) Closing as per above comments. Verified without stringifying:
        var rect = cropRectView.rect;
              Ti.API.info(rect.x+' '+rect.y+' '+rect.width+' '+rect.height)
       
    Getting the expected output. Hence closing as fixed and verified.

JSON Source