Titanium JIRA Archive
Titanium SDK/CLI (TIMOB)

[TIMOB-16540] iOS7: TableViewRow: leftImage property renders improper image alignment

GitHub Issuen/a
TypeBug
PriorityMedium
StatusClosed
ResolutionInvalid
Resolution Date2014-03-26T21:57:41.000+0000
Affected Version/sRelease 3.2.2
Fix Version/sn/a
ComponentsiOS
Labelsqe-3.2.2, supportTeam, triage
ReporterParas Mishra
AssigneeSabil Rahim
Created2014-03-03T07:18:43.000+0000
Updated2017-03-20T20:37:47.000+0000

Description

iOS7: TableViewRow: leftImage property renders improper image allignment. It works fine on iOS 6 device(iPOD touch iOS:6.1.3). Issue also occurs on 3.2.1.GA,3.2.0.GA sdk Steps to reproduce: 1. Run the below app.
var win = Ti.UI.createWindow({
	backgroundColor: 'red'
});
createTableRow = function(args){
		  // save the title for our own use
		  var title = args.title;
		  args.title = '';
		  args.left = 42;
		  args.height = 40;
		 
		  var row = Ti.UI.createTableViewRow(args);
		 
		  var label = Ti.UI.createLabel({
		    backgroundColor: 'pink',
		    text: title,
		    textAlign: Ti.UI.TEXT_ALIGNMENT_LEFT,
		    width: Ti.UI.FILL,
		    height: args.height - 5,
		    left: args.left,
		    font: { fontSize: 17, fontWeight: 'bold'},
		  });
		 
		  row.add(label);
		 
		  row.label_title = title;
		 
		  return row;
		};
		 
		var rows = [];
		rows.push( createTableRow({ title: 'table', leftImage: '/KS_nav_ui.png'}) );
		rows.push( createTableRow({ title: 'row', leftImage: '/KS_nav_ui.png'}) );
		rows.push( createTableRow({ title: 'rock' }) );
		rows.push( createTableRow({ title: 'car', leftImage: '/KS_nav_ui.png'}) );
		rows.push( createTableRow({ title: 'tab' }) );
		rows.push( createTableRow({ title: 'row boat', leftImage: '/KS_nav_ui.png'}) );
		rows.push( createTableRow({ title: 'table row', leftImage: '/KS_nav_ui.png'}) );
		rows.push( createTableRow({ title: 'test', leftImage: '/KS_nav_ui.png'}) );
		rows.push( createTableRow({ title: 'apple' }) );
		 
		var search = Ti.UI.createSearchBar({
		  showCancel: false
		});
		 
		var table = Ti.UI.createTableView({
		  data: rows,
		  search: search,
		  searchHidden: false,
		  filterAttribute: 'label_title',
		  filterCaseInsensitive: true
		});
		 
		win.add(table);
		 
		win.open();

Expected: left image in tableviewrow should be properly alligned. Actual: left image overlaps with the label. Screenshots are attached for iOS7 and iOS:6 devices.

Attachments

FileDateSize
row_iOS_6.PNG2014-03-03T07:18:43.000+000061569
row_iOS_7.PNG2014-03-03T07:18:43.000+000052521

Comments

  1. Sabil Rahim 2014-03-25

    [~egomez] Here is the solution that would work on both ios 6 & 7
       var win = Ti.UI.createWindow({
           backgroundColor: 'red'
       });
       createTableRow = function(args){
       	// save the title for our own use
       	var title = args.title;
       	args.title = '';
       	args.left = 45;
       	args.height = 40;
       	var leftImage = args.leftImage;
       	args.leftImage = '';
       
       	var container = Ti.UI.createView({
       		layout : "horizontal",
       		width : Ti.UI.FILL,
       		height : Ti.UI.FILL,
       	});
       
       	
       	if (leftImage) {
       		var image = Ti.UI.createImageView({
       			image:leftImage,
       			width: 40,
       			height: args.height - 5
       		});
       		args.left= 5;
       		Ti.API.info("args.left : " + args.left);
       		container.add(image);
       	}
       	
       	var row = Ti.UI.createTableViewRow(args);
       	var label = Ti.UI.createLabel({
       		backgroundColor: 'pink',
       		text: title,
       		textAlign: Ti.UI.TEXT_ALIGNMENT_LEFT,
       		width: Ti.UI.FILL,
       		height: args.height - 5,
       		left: args.left,
       		font: { fontSize: 17, fontWeight: 'bold'},
       	});
       	
       
       	
       	container.add(label)
       	row.add(container);
       
       	row.label_title = title;
       
       	return row;
       };
       
       var rows = [];
       rows.push( createTableRow({ title: 'table', leftImage: '/KS_nav_ui.png'}) );
       rows.push( createTableRow({ title: 'row', leftImage: '/KS_nav_ui.png'}) );
       rows.push( createTableRow({ title: 'rock' }) );
       rows.push( createTableRow({ title: 'car', leftImage: '/KS_nav_ui.png'}) );
       rows.push( createTableRow({ title: 'tab' }) );
       rows.push( createTableRow({ title: 'row boat', leftImage: '/KS_nav_ui.png'}) );
       rows.push( createTableRow({ title: 'table row', leftImage: '/KS_nav_ui.png'}) );
       rows.push( createTableRow({ title: 'test', leftImage: '/KS_nav_ui.png'}) );
       rows.push( createTableRow({ title: 'apple' }) );
       
       var search = Ti.UI.createSearchBar({
       	showCancel: false
       });
       
       var table = Ti.UI.createTableView({
       	data: rows,
       	search: search,
       	searchHidden: false,
       	filterAttribute: 'label_title',
       	filterCaseInsensitive: true
       });
       
       win.add(table);
       
       win.open();
       
  2. Vishal Duggal 2014-03-26

    Use leftImage, rightImage properties with title property. If you are creating a custom layout, then don't use the built in properties, rather create your own ImageViews to show images
  3. Eduardo Gomez 2014-03-27

    [~vduggal] Is there a recommended approach for adding the rows to table using insertRowBefore method. Please see the above code posted the 19/Mar/14. Because of this Client is getting the alignment issues. Is there any workaround for this?
  4. Lee Morris 2017-03-20

    Closing ticket as invalid.

JSON Source