Titanium JIRA Archive
Titanium SDK/CLI (TIMOB)

[TIMOB-7451] iOS: Left property of the view is not being set in the correct position in the device

GitHub Issuen/a
TypeBug
PriorityHigh
StatusClosed
ResolutionCannot Reproduce
Resolution Date2012-03-15T12:46:40.000+0000
Affected Version/sRelease 1.8.0.1, Release 2.0.0
Fix Version/sn/a
ComponentsiOS
Labelsn/a
ReporterFrancisco Antonio Duran Ramirez
AssigneeMax Stepanov
Created2012-01-27T11:40:48.000+0000
Updated2012-03-30T13:09:51.000+0000

Description

Problem

Left property of the view is not working correctly in the device.

Reproducible steps:

1. Test the code below in the device with 1.8.0.1 Titanium SDK. Please see the behavior in the Device-1.8.0.1 Ti SDK-5.01 iOS SDK.mov attached video. 2. Test the code below in the simulator with 1.8.0.1 Titanium SDK. Please see the behavior in the Simulator-1.8.0.1 Ti SDK-5.01 iOS SDK.mov attached video. Note: In the device, and simulator you will get different behavior. 3. Test the code below in the device, and simulator with 1.7.5 Titanium SDK. Note: Good behavior. Same behavior in the device, and simulator using 1.7.5 Titanium SDK.

Expected behavior:

Customer wants to have the same behavior in the device using 1.8.0.1 Titanium SDK like Simulator-1.8.0.1 Ti SDK-5.01 iOS SDK attached video.

More info:

Note: Good behavior in device with 1.7.5 Titanium SDK

Tested with the next specs:

Simulator Titanium Studio, build: 1.0.9.201201251947 iOS SDK: 5.0.1 Titanium SDK: 1.8.0.1 & 1.7.5 Device: iphone 4. Version of the device: 5.0.1

Code:

var App = {};
var
	createBottomView,
	createWindow,
	changeOrientation,
	setPortrait,
	setLandscape
;

var
	galleryViewWin,
	previewPane,
	bottomViews = []
;

changeOrientation = function() 
{
	switch (Ti.UI.orientation) 
	{
		case Ti.UI.PORTRAIT:
		case Ti.UI.UPSIDE_PORTRAIT:
			setPortrait();
			break;
		case Ti.UI.LANDSCAPE_LEFT:
		case Ti.UI.LANDSCAPE_RIGHT:
			setLandscape();
			break;
		default:
	}
};

setLandscape = function() 
{
	var i;
	
	previewPane.top = 4;
	previewPane.left = 155;

	for(i=0; i<bottomViews.length; i++) 
	{
		bottomViews[i].changeToLandscape();
	}
};

setPortrait = function() 
{
	var i;
	previewPane.top = 60;
	previewPane.left = null;
	for(i=0; i<bottomViews.length; i++) 
	{
		bottomViews[i].changeToPortrait();
	}
};

createWindow = function() 
{
	return Ti.UI.createWindow(
	{
		tabBarHidden: true,
		barColor: '#111',
		orientationModes: [Ti.UI.LANDSCAPE_LEFT, Ti.UI.LANDSCAPE_RIGHT,Ti.UI.PORTRAIT, Ti.UI.UPSIDE_PORTRAIT]
	});
};

createBottomView = function(bottom) 
{
	var self;

	self = Ti.UI.createView({
		visible: false,
		borderColor: 'blue',
		height: 40,
		bottom: bottom,
		backgroundColor: 'transparent'
	});
	
	self.changeToPortrait = function() 
	{
		self.left = 0;
		self.right = 160;
		Ti.API.info('self.left: ' + self.left);
		Ti.API.info('self.getLeft: ' + self.getLeft());
		self.borderColor = 'red';			
	};
	
	self.changeToLandscape = function() 
	{
		self.left = 240;
		self.right = 0;
		self.borderColor = 'yellow';
		Ti.API.info('self.left: ' + self.left);
		Ti.API.info('self.getLeft: ' + self.getLeft());
	};
	
	return self;
};

App.tabGroup = Titanium.UI.createTabGroup();
App.tab = Titanium.UI.createTab({});

App.tabGroup.addTab(App.tab);
App.tabGroup.open();
galleryViewWin = createWindow();

previewPane = Ti.UI.createView(
{
	height: 221,
	width: 221*4/3,
	borderWidth: 1,
	borderRadius: 1,
	backgroundColor: '#d9d8d8'
});

previewPane.addEventListener('click', function() 
{
	var i;
	for(i=0; i<bottomViews.length; i++) 
	{
		bottomViews[i].visible = true;
	}
});

galleryViewWin.add(previewPane);

var i;
for(i=0; i<5; i++) 
{
	bottomViews.push(createBottomView(i*20));
	galleryViewWin.add(bottomViews[i]);
}

Ti.Gesture.addEventListener('orientationchange',changeOrientation);

setPortrait();
galleryViewWin.title = 'Win Title';
App.tab.open(galleryViewWin);

Helpdesk

APP-985465

Attachments

FileDateSize
Device-1.8.0.1 Ti SDK-5.01 iOS SDK.mov2012-01-27T11:40:48.000+00004790475
Simulator-1.8.0.1 Ti SDK-5.01 iOS SDK.mov2012-01-27T11:40:48.000+00001660340

Comments

  1. Max Stepanov 2012-03-15

    The sample code works as expected after recent layout improvements.
  2. Michael Pettiford 2012-03-30

    Closing issue Tested with Ti Studio build 2.0.0.201203291340 Ti Mobile SDK 2.0.0.v20120329191102 hash r1fbf18c4 OSX Lion 10.7.3 iPhone 4S OS 5.1, iPhone Sim OS 5.0 Cannot reproduce issue

JSON Source