How do I make a UITableViewCell separator show up? - ios

I'm having a similar problem to this question: UITableViewCell separator not showing up.
However, the proposed solutions don't work for me. Specifically, I've checked the following:
My UITableViewCell subclass does not override drawRect:.
I don't have a custom UITableView and, therefore, I'm not overriding layoutSubviews.
In Interface Builder, I have the Separator attribute of the Table View set to "Single Line".
I've tried programmatically setting tableView.separatorStyle to UITableViewCellSeparatorStyleSingleLine.
But still the separator line will now show up… Does anyone know of something else that could cause this behavior or have any ideas for how I might track down what is hiding/removing the separator line?
EDIT:
Well I feel silly… In trying to create the screenshot requested by valheru, I noticed that the lines ARE there, but are almost exactly the same color as the background, so I couldn't see them until the screenshot was blown up. I had suspected earlier that the separator color might be the issue, and I tried testing for that by setting the separator color to white (my background is almost black), but it turns out that there was some copy/pasted code that was programmatically resetting the color to the almost-invisible color.
Thanks valheru for leading me to the answer. :-)

Check the height of your table view's row and the height of the cell. Make sure that the row's height is not less than the cell's height.

Related

ios tableview last cell in table missing separator swift

My table view's last cell was working fine and showing a separator. However when testing my app now I realized that the separator no longer comes up anymore for the last cell of the table. The only thing I can think of that might have caused this to happen was playing around with some of the preset tableview settings in main.storyboard.I checked but didn't notice anything different. Any one know what I might have changed to cause this, or now what to try to fix it ? Thank you
By default, the last cell of a tableView does not show a separator. Someway to work around it include using a 1px UIView with background Color as separator.
The other way I prefer doing is to set a footer view. Something like this:
self.tableView.tableFooterView = UIView(frame: CGRect.zero)
By setting a tableFooterView the last cell would show a separator.

iPhone 6 Plus show strange lines in UITableViewCell next to the accessoryView

I have a UITableView that is showing some strange thin grey lines next to the accessory view. This ONLY happens on the plus, no other iPhone shows this issue.
It seems to have something to do with the imageView that is assigned to the cell. Some images cause the line, others don't, seemingly based on their dimensions.
Has anyone else seen this or know how to get rid of it?
I experienced this when using a UITableView that was partially covered with an SWRevealViewController.
When the calculated value of the tableview width was a decimal number, artifact lines between the content of a UITableViewCell and the accessory view would appear.
The solution was to make sure that size calculations for the view were rounded to whole numbers.
It looks like that line is from the right edge of the cell's content view. I don't know how it works, but my solution was:
cell.backgroundColor = .clear

I've added a view within a UITableView and there is a gap between the view and the first cell. How can I remove it?

I've added a view to a tableView and there is a gap between the view which is 44px high and the first cell.
Here's a screen shot from IB:
I've tried a few things such as changing the heightForHeaderInSection's value and also disabled adjust scroll view insets. None of these work properly. The view seems to be within the tableView and scrolls with it.
This is how things are looking in simulator:
Would appreciate some help here as I don't understand what exactly is causing this gap.
Thanks for your time
A great way to debug these types of problems is to set a background color. You could set the cells to red and the view to green. It would then be interesting to see if the red and green edges are flush with no white in between.
Based on your screenshot, it looks like nothing is wrong. And by that I mean it looks about right for a view height of 44 points and a cell immediately beneath it with no separator line above it (so it's hard to tell where one ends and the other begins).

Unable to consistently set size of UITextField

I have a UItableViewController, with a UITextField in each cell, pretty basic. I decided to get a bit fancy and alternate the row colors by setting the background color of the text field.
What I noticed is that the text field background color does not match up with the table rows. The width is shorter and the height and position is wrong too.
I tried setting the dimensions of the frame of the text field in cellForRowAtIndexPath. I also tried the same in willDisplayCell. I also tried to muck around with other frames, like the cell frame, to no avail.
I've had some some luck in setting the text field frame size in layoutSubviews in my UITableViewCell subclass, but it still acts strangely. When the table first displays, everything looks right. I click my edit button, and everything still looks right. I click the done button and I'm back to the old problem with both the width and height too short. Checking in the debugger, I am setting everything to the correct values.
More Information:
I have the same problem with some tables which have UILabels instead of UITextFields. All of the tables have fixed size rows. I initially set up the tables with the interface builder, but I'm trying to set the frame sizes programmatically. I am using the latest and greatest Xcode 5 (5.1.1).
Anyone have any suggestions? Where am I supposed to set the frame size? Is there another object that I should be setting the size of?
Thanks in advance

Change custom cell's background without IB

I'm overloading my brains on this one.
I've created a table, which contains custom cells (one of a kind). A few days back, I changed the background to the grey you can see in the picture below here.
Now I don't know how I did that....
I don't think I did this programatically... What else would explain the color in IB?
I also searched my sourcecode, and the line for coloring the cell through code is commented out.
I need to reproduce this coloring on other custom cells. How the heck did I do this? :D
Ah, I thought of the answer while getting a cup of coffee:
Change the tableView's background (so, an other .xib-file) to the grey color to get that effect...

Resources