Titanium JIRA Archive
Titanium SDK/CLI (TIMOB)

[TIMOB-7203] iOS: UI.View - make size property read-only

GitHub Issuen/a
TypeBug
PriorityMedium
StatusClosed
ResolutionInvalid
Resolution Date2012-01-17T08:38:36.000+0000
Affected Version/sRelease 1.8.0.1
Fix Version/sn/a
ComponentsiOS
Labelsparity
ReporterPaul Dowsett
AssigneeNeeraj Gupta
Created2012-01-16T09:39:38.000+0000
Updated2017-03-09T23:14:28.000+0000

Description

Comments

  1. Paul Dowsett 2012-01-16

    The above test case proves that the size property is read-only. Closing as invalid.
  2. Paul Dowsett 2012-01-16

    Note that the behavior is the same for Android, although there are bugs presently that mean that size is not correct unless the window is heavyweight, view is already rendered, used within an window open event and the first open event is ignored, as per the following code:
       var win = Ti.UI.createWindow({
         fullscreen:false,
         backgroundColor:'red'
       });
       
       var view = Ti.UI.createView({
         backgroundColor:'blue',
         width:50,
         height:50
       });
       
       win.add(view);
       win.open();
       
       var openEventCount = 0;
       
       win.addEventListener('open', function() {
         openEventCount++;
         Ti.API.info("------- Window event fired: open --------");
         if(openEventCount === 2){
           Ti.API.info("*** Before width changes 50 ***");
           Ti.API.info("view.size w x h: " + view.size.width + " x " + view.size.height);
           Ti.API.info("view w x h: " + view.width + " x " + view.height);
       
           Ti.API.info("*** view.size.width change 100 ***");
           view.size.width = 100; // this should NOT work
           Ti.API.info("view.size w x h: " + view.size.width + " x " + view.size.height);
           Ti.API.info("view w x h: " + view.width + " x " + view.height);
       
           Ti.API.info("*** view.width change 200 ***");
           view.width = 200; // this should work
           Ti.API.info("view.size w x h: " + view.size.width + " x " + view.size.height);
           Ti.API.info("view w x h: " + view.width + " x " + view.height);
         }
       });
       
       D/AndroidRuntime( 1308): >>>>>>>>>>>>>> AndroidRuntime START <<<<<<<<<<<<<<
       I/TiApplication( 1309): (main) [321,321] Titanium 1.8.0.1 (2011/12/22 13:09 fbdc96f)
       I/TiApplication( 1309): (main) [8,656] Titanium Javascript runtime: v8
       D/TiAssetHelper( 1309): Fetching "app.js" with Fastdev...
       I/TiAPI   ( 1309): ------- Window event fired: open --------
       I/TiAPI   ( 1309): ------- Window event fired: open --------
       I/TiAPI   ( 1309): *** Before width changes 50 ***
       I/TiAPI   ( 1309): view.size w x h: 50 x 50
       I/TiAPI   ( 1309): view w x h: 50 x 50
       I/TiAPI   ( 1309): *** view.size.width change 100 ***
       I/TiAPI   ( 1309): view.size w x h: 50 x 50
       I/TiAPI   ( 1309): view w x h: 50 x 50
       I/TiAPI   ( 1309): *** view.width change 200 ***
       I/TiAPI   ( 1309): view.size w x h: 50 x 50
       I/TiAPI   ( 1309): view w x h: 200 x 50
       
  3. Paul Dowsett 2012-01-17

    In case a race condition is involved, I wrapped a setTimeout around the logging lines, and confirmed view.size.width value is read-only. Hence, closing.
  4. Lee Morris 2017-03-09

    Closing ticket as invalid.

JSON Source