UITableView separators don't show after changing table background color - MacRumors Forums
Register FAQ / Rules Forum Spy Search Today's Posts Mark Forums Read
Go Back   MacRumors Forums > Apple Systems and Services > Programming > iPhone/iPad Programming

Reply
 
Thread Tools Search this Thread Display Modes
Old Feb 18, 2013, 07:43 PM   #1
straber
macrumors member
 
Join Date: Jul 2012
UITableView separators don't show after changing table background color

I have a UITableView, and when I set its background color to gray, the separator between the cells doesn't show. The separator color is set to white, and if I don't change the table's background color, the separators show up fine. Does anyone know why this is or how to fix it?

Thanks in advance...
straber is offline   0 Reply With Quote
Old Feb 18, 2013, 09:46 PM   #2
xStep
macrumors 68000
 
Join Date: Jan 2003
Location: Lost in Minneapolis
If you're using code to set this all up, lets see it. If your are using the IB editor, then post the details via image captures.
__________________
My App: CameraTime - Time lapse photography for novice and advanced users.
xStep is offline   0 Reply With Quote
Old Feb 18, 2013, 10:33 PM   #3
straber
Thread Starter
macrumors member
 
Join Date: Jul 2012
This code is in the UITableViewController

in viewDidLoad:

Code:
self.tableView.separatorStyle  = UITableViewCellSeparatorStyleSingleLineEtched;
    self.tableView.separatorColor  = [UIColor whiteColor];
    self.tableView.backgroundColor = [UIColor colorWithRed:230.0 / 255.0 green:230.0 / 255.0 blue:230.0 / 255.0 alpha:1.0];
and in tableView: cellForRowAtIndexPath

Code:
cell.contentView.backgroundColor = [UIColor colorWithRed:230.0 / 255.0 green:230.0 / 255.0 blue:230.0 / 255.0 alpha:1.0];
    cell.textLabel.backgroundColor = [UIColor clearColor];
If I don't change the background color of the table, everything below the last cell is white, but the separators show, if I do change the background color, everything is the same color, but the separators don't show.
straber is offline   0 Reply With Quote
Old Feb 18, 2013, 11:08 PM   #4
dejo
Moderator
 
dejo's Avatar
 
Join Date: Sep 2004
Location: The Centennial State
Have you tried setting the backgroundColor before setting the separatorColor?
__________________
dejo is online now   0 Reply With Quote
Old Feb 18, 2013, 11:11 PM   #5
straber
Thread Starter
macrumors member
 
Join Date: Jul 2012
Yes, I did try that with no luck. The separators still didn't show.
straber is offline   0 Reply With Quote
Old Feb 18, 2013, 11:24 PM   #6
dejo
Moderator
 
dejo's Avatar
 
Join Date: Sep 2004
Location: The Centennial State
Quote:
Originally Posted by straber View Post
Yes, I did try that with no luck. The separators still didn't show.
Alright, thought it was worth a shot. Thanks for trying.
__________________
dejo is online now   0 Reply With Quote
Old Feb 19, 2013, 01:15 PM   #7
straber
Thread Starter
macrumors member
 
Join Date: Jul 2012
The issue seems to be that the backgroundColor property overrides the separatorColor property because regardless of what I set the separatorColor to, the separator lines end up being whatever color I set the backgroundColor to. I was setting the backgroundColor to the same color as my table cells so that the area under the last cell would be the same color, but this was making the separators the same color as the table cells, giving the appearance that they weren't there.
straber is offline   0 Reply With Quote
Old Feb 19, 2013, 06:41 PM   #8
xStep
macrumors 68000
 
Join Date: Jan 2003
Location: Lost in Minneapolis
UITableViewCellSeparatorStyleSingleLineEtched is "currently only supported for grouped-style table views". Try UITableViewCellSeparatorStyleSingleLine in it's place.

Also, given the code you mentioned, you should not need the two lines in the cellForRowAtIndexPath: method.
__________________
My App: CameraTime - Time lapse photography for novice and advanced users.
xStep is offline   0 Reply With Quote

Reply
MacRumors Forums > Apple Systems and Services > Programming > iPhone/iPad Programming

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Similar Threads
thread Thread Starter Forum Replies Last Post
UITableView in table view controller is cut off at the top moonman239 iPhone/iPad Programming 3 Nov 21, 2013 12:10 PM
White background for photos. Don't read if you don't want to read another moan thread snerkler iOS 7 2 Jun 15, 2013 03:14 PM
How do I change the color of text in a table using pages J.Wildflower iPad Tips, Help and Troubleshooting 4 Jun 5, 2013 09:50 AM
Facebook, don't show me stories from pages I don't like chrf097 Community Discussion 11 Apr 11, 2013 02:04 PM
Limit Table View Rows to show 1 row only newtoiphonesdk iPhone/iPad Programming 0 Dec 16, 2012 09:37 PM

Forum Jump

All times are GMT -5. The time now is 11:20 AM.

Mac Rumors | Mac | iPhone | iPhone Game Reviews | iPhone Apps

Mobile Version | Fixed | Fluid | Fluid HD
Copyright 2002-2013, MacRumors.com, LLC