{ "id": "62370", "key": "TIMOB-1738", "fields": { "issuetype": { "id": "1", "description": "A problem which impairs or prevents the functions of the product.", "name": "Bug", "subtask": false }, "project": { "id": "10153", "key": "TIMOB", "name": "Titanium SDK/CLI", "projectCategory": { "id": "10100", "description": "Titanium and related SDKs used in application development", "name": "Client" } }, "fixVersions": [ { "id": "11240", "name": "Release 1.6.0 M07", "archived": true, "released": true, "releaseDate": "2011-01-31" } ], "resolution": { "id": "1", "description": "A fix for this issue is checked into the tree and tested.", "name": "Fixed" }, "resolutiondate": "2011-04-17T01:57:01.000+0000", "created": "2011-04-15T03:00:56.000+0000", "priority": { "name": "Low", "id": "4" }, "labels": [ "apple", "bug", "defect", "ios", "ipad", "release-1.6.0", "tableview" ], "versions": [], "issuelinks": [], "assignee": { "name": "blainhamon", "key": "blainhamon", "displayName": "Blain Hamon", "active": true, "timeZone": "America/Los_Angeles" }, "updated": "2011-04-17T01:57:01.000+0000", "status": { "description": "The issue is considered finished, the resolution is correct. Issues which are closed can be reopened.", "name": "Closed", "id": "6", "statusCategory": { "id": 3, "key": "done", "colorName": "green", "name": "Done" } }, "components": [ { "id": "10206", "name": "iOS", "description": "iOS Platform" } ], "description": "{html}
On 3.2 the grouped table view does not honor background color\nproperty. The Rows will change color but the background around the\nview always stays gray.
\nvar win = Ti.UI.currentWindow;
\nwin.backgroundColor = '#FFF';
var data = [];
\nfor (var c=0;c<4;c++)
\n{
\ndata[c] = Ti.UI.createTableViewSection({headerTitle:'Group '+(c+1)});\nfor (var x=0;x<10;x++)\n{\n data[c].add(Ti.UI.createTableViewRow({title:'Group '+(c+1)+', Row '+(x+1),backgroundColor:'#FF0000'}));\n}
\n
\n}
\n// create table view var tableview =\nTitanium.UI.createTableView({
\ndata:data,\nstyle: Titanium.UI.iPhone.TableViewStyle.GROUPED,\nbackgroundColor:'transparent'
\n
\n});
\n// create table view event listener\ntableview.addEventListener('click', function(e)
\n{
\n// event data\nvar index = e.index;\nvar section = e.section;\nvar row = e.row;\nvar rowdata = e.rowData;\nif (section.headerTitle.indexOf('clicked')==-1)\n{\n section.headerTitle = section.headerTitle + ' (clicked)';\n}\nTitanium.UI.createAlertDialog({title:'Table View',message:'row ' + row + ' index ' + index + ' section ' + section + ' row data ' + rowdata}).show();
\n
\n});
\n// add table view to the window\nTitanium.UI.currentWindow.add(tableview);
I found a solution to make the 'backgroundColor' works in\nTableViewStyle.GROUPED.
\nThis solution will set the tableview default backgroundColor to\n'transparent', and will correct ANY color applied to it.
I Tested this with successful in 1.4.2 and 1.5.0
\nIf you want correct only for your project:
\nIf you want correct all projects:
\nFind these lines:
\n\n\n tableview.backgroundColor = style == UITableViewStylePlain ? [UIColor whiteColor] : [UIColor groupTableViewBackgroundColor];\n tableview.opaque = YES;
\n
\nand change to this code:
\n\n\n //tableview.backgroundColor = style == UITableViewStylePlain ? [UIColor whiteColor] : [UIColor groupTableViewBackgroundColor];\n //tableview.opaque = YES;\n\n // CORRECTION FOR TRANSPARENT TABLEVIEW\n if (style != UITableViewStylePlain)\n {\n UIView *myBackgroundView = [[UIView alloc] initWithFrame:CGRectMake(0, 0, [self bounds].size.width, [self bounds].size.height)];\n id BgColor = [self valueForKey:@\"backgroundColor\"];\n if (BgColor!=nil)\n {\n myBackgroundView.backgroundColor = [Webcolor webColorNamed:BgColor];\n }\n else\n {\n myBackgroundView.backgroundColor = [UIColor clearColor];\n }\n tableview.backgroundView = myBackgroundView;\n }\n // CORRECTION FOR TRANSPARENT TABLEVIEW
\n
Adriano, does that introduce a memory leak? I see an alloc\nwithout a release.
Ops, sorry James K, you right!
\nchage this:
\n\nUIView *myBackgroundView = [[UIView alloc] initWithFrame:CGRectMake(0, 0, [self bounds].size.width, [self bounds].size.height)];
\n
\nto this:
\n\nUIView *myBackgroundView = [[UIView alloc] initWithFrame:CGRectMake(0, 0, [self bounds].size.width, [self bounds].size.height) autorelease];
\n
\nSorry for that!
SORRY again.....
\ni forgot the brackets....
\nCorrect (and tested) code:
\n\n\n //tableview.backgroundColor = style == UITableViewStylePlain ? [UIColor whiteColor] : [UIColor groupTableViewBackgroundColor];\n //tableview.opaque = YES;\n \n // CORRECTION FOR TRANSPARENT TABLEVIEW\n if (style != UITableViewStylePlain)\n {\n UIView *myBackgroundView = [[[UIView alloc] initWithFrame:CGRectMake(0, 0, [self bounds].size.width, [self bounds].size.height)] autorelease];\n id BgColor = [self valueForKey:@\"backgroundColor\"];\n if (BgColor!=nil)\n {\n myBackgroundView.backgroundColor = [Webcolor webColorNamed:BgColor];\n }\n else\n {\n myBackgroundView.backgroundColor = [UIColor clearColor];\n }\n tableview.backgroundView = myBackgroundView;\n }\n // CORRECTION FOR TRANSPARENT TABLEVIEW
\n
(from [1b85b06736303aede99672606c5e72319a2ff8dc])\n[#1738 state:fixed-in-qa] Respect tableview BG\ncolor on creation, and only opaque out if not clear. \nhttps://github.com/appcelerator/titanium_mobile/commit/1b85b0673630...
Tested this code on iPad simulator and iPad, iOS 4.2
\n\nvar win = Ti.UI.createWindow({backgroundColor:'green'});\nvar data = [];\nfor(var i=0;i<10;i++){\n data[i] = Ti.UI.createTableViewRow({title:'Row #'+i});\n}\nvar tableview = Ti.UI.createTableView({\n data:data,\n style:Titanium.UI.iPhone.TableViewStyle.GROUPED,\n backgrounColor:'#5A9ECF'\n});\nwin.add(tableview);\nwin.open();
\n
\nProblem persists.
\nTi. SDK 1.6 (Jan 25 2011 17:39 r1ead074f)
In this new version made the correction as follows:
\nafter this line:
\n\ntableview.opaque = ![tableview.backgroundColor isEqual:[UIColor clearColor]];
\n
\nI added:
\n\n// CORRECTION FOR TRANSPARENT/COLOR BACKGROUND IN TABLEVIEW ON IPAD\nif(style != UITableViewStylePlain && [TiUtils isIPad])\n{\n UIView *myBackgroundView = [[[UIView alloc] initWithFrame:CGRectMake(0, 0, [self bounds].size.width, [self bounds].size.height)] autorelease];\n myBackgroundView.backgroundColor = bgColor != nil ? bgColor : [UIColor clearColor];\n tableview.backgroundView = myBackgroundView;\n}\n// CORRECTION FOR TRANSPARENT/COLOR BACKGROUND IN TABLEVIEW ON IPAD
\n
Example provided works as expected when\nbackgroundColor
doesn't contain a typo:
\nvar win = Ti.UI.createWindow({backgroundColor:'green'});\nvar data = [];\nfor(var i=0;i<10;i++){\n data[i] = Ti.UI.createTableViewRow({title:'Row #'+i});\n}\nvar tableview = Ti.UI.createTableView({\n data:data,\n style:Titanium.UI.iPhone.TableViewStyle.GROUPED,\n backgroundColor:'#5A9ECF'\n});\nwin.add(tableview);\nwin.open();
\n
\nIf table rows adopting table background color/using UIClearColor\nis considered a bug and NOT expected behavior (i.e. this is not\nwhat Android does), that is a separate bug and\nthis ticket should not be reopened.
Stephen,
\nDon't know if I'm testing this the wrong way, but I can't change\nthe background of the tableview itself. This is the new code
\nvar win = Ti.UI.createWindow({backgroundColor:'green'});\nvar data = [];\nfor(var i=0;i<10;i++){\n data[i] = Ti.UI.createTableViewRow({title:'Row #'+i,backgroundColor:'yellow'});\n}\nvar tableview = Ti.UI.createTableView({\n data:data,\n style:Titanium.UI.iPhone.TableViewStyle.GROUPED,\n backgroundColor:'#000'\n});\nwin.add(tableview);\nwin.open();
\n
\nI'm setting the background of the tableView black and the rows\nyellow. The background of the tableView does not change, even if I\nremove the background color of the rows.
\nAnd sorry for the typo, oops.
\nTi SDK 1.6 (Jan 26 2011 14:27 r6342c788)
\nTiDev 1.2 and 1.3
\niPad Simulator 4.2
OK, this works on iPhone (what I fixed the bug for) but not\niPad. Reopening.
(from [5cc2ed4bdf5fcd57edfd6c86d0e3201bfb1d5997])\n[#1738 state:fixed-in-qa] Fixed for iPad as well\n- there's an iPad-specific apple bug that screws up tableview\nbackground colors. Probably also affects BG images. \nhttps://github.com/appcelerator/titanium_mobile/commit/5cc2ed4bdf5f...
Confirmed that this is an apple bug. It's less than ideal, but\nI've added in the proposed solution of just outright replacing the\nbackground view in the case of iPad.
\nRadar bug # is 8921858.
Yes!
\nNow it works as expected.
\nTi. SDK 1.6 (Jan 26 2011 16:47 rb481fe0b)
\niPad Simulator 4.2
\nTi. Dev. 1.3
Border color is transparent
I just tested what Marko is referring. Only on iPad a grouped\nview's border is semi-transparent. Workaround is to explicitly set\nthe separatorColor to the tableView object.
\nHe's attached two images here to give an example: http://developer.appcelerator.com/helpdesk/view/66191#c324451