Titanium JIRA Archive
Titanium SDK/CLI (TIMOB)

[TIMOB-15398] iOS: View - postLayout event gets called twice

GitHub Issuen/a
TypeBug
PriorityLow
StatusOpen
ResolutionUnresolved
Affected Version/sRelease 3.1.3
Fix Version/sn/a
ComponentsiOS
LabelsSupportTeam, reprod
ReporterDavid He
AssigneeUnknown
Created2013-10-04T04:55:12.000+0000
Updated2018-02-28T20:04:25.000+0000

Description

Problem Description

The postlayout event is fired twice, therefore the callback is called twice as well.

Steps to reproduce

1. Create a new mobile project (Classic Titanium) 2. Paste the code sample to app.js 3. Run the code in the simulator 4. Please check the console when running, you will be able to see that the width and the height value are changing twice. They should change once.
[INFO] :  e.source.rect.width 320
[INFO] :  e.source.rect.height 216
[INFO] :  e.source.rect.width 320
[INFO] :  e.source.rect.height 216

Test case

var win = Ti.UI.createWindow();
var btn = Ti.UI.createButton();
win.setLeftNavButton(btn);

btn.addEventListener('click', function(e) {
	win.close();
});

var picker = Ti.UI.createPicker({
	type : Ti.UI.PICKER_TYPE_DATE,
	minDate : new Date(2009, 0, 1),
	maxDate : new Date(2014, 11, 31),
	value : new Date(2014, 3, 12),
	visible : true
});

var view = Ti.UI.createView({
	bottom : -279,
	width : Ti.UI.SIZE,
	height : Ti.UI.SIZE
});

var slide_in = Titanium.UI.createAnimation({
	bottom : 0,
	duration : 200,

});
var slide_out = Titanium.UI.createAnimation({
	bottom : -304,
	duration : 200
});

view.addEventListener("postlayout", function(e) {
	Ti.API.info('e.source.rect.width'+e.source.rect.width);
	Ti.API.info('e.source.rect.height'+e.source.rect.height);
});

view.add(picker);
win.add(view); 

win.open();

Comments

  1. Shameer Jan 2014-08-08

    Issue reproduces Titanium Command-Line Interface, CLI version 3.3.0, Titanium SDK version 3.3.0.GA iOS SDK: 7.1 iOS iPhone Simulator: 7.1
  2. Lee Morris 2017-05-23

    Can confirm that this is still an issue. Tested with the following environment; iPhone 7 (10.2) MacOS 10.11.6 (15G31) Studio 4.9.0.201705021158 Ti SDK 6.1.0.v20170519131839 Appc NPM 4.2.9 Appc CLI 6.2.1 Ti CLI 5.0.13 Alloy 1.9.11 Arrow 2.0.0 Xcode 8.2 (8C38) Node v4.8.2 Java 1.7.0_80

JSON Source