Moondra
Moondra

Reputation: 4511

Separator lines don't show up under custom tableView cells despite enabling it in Attributes inspector

So I went to Attributes inspector of my TableView and added a "single line" separator as follows:

enter image description here

The separator seems to be appearing in the Storyboard tableView

However, when I run the app: No lines

This was done via Storyboard so not sure what else information is needed. Just incase I've uploaded it to Github using xcode source control:

https://github.com/bigmit2011/TableView-TableView

Any clues as to what I'm doing wrong?

Upvotes: 0

Views: 63

Answers (2)

Shehata Gamal
Shehata Gamal

Reputation: 100503

You need to set the constraints correctly

1- For the stackView give it leading , trailing ,top,bottom to container

2- For the imageview inside the cell give it leading

3- Either implement heightForRowAt and return a height , or set top & bottom constraints to the label and set automatic in viewDidLoad

tableView.estimatedRowHeight = 150    
tableView.rowHeight = UITableViewAutomaticDimension

Try fixing these issues then see if the separator will show or not

//

I have created a demo check Here , also make sure if you run in simulator to zoom or increase Scale as the separator disappear in small scales

//

enter image description here

Upvotes: 1

Tj3n
Tj3n

Reputation: 9923

The possible reason is that you are running in a very large screen simulator and you are scaling it down to small size, the simulator will sometimes compress the thin view, such as separator line, into nothingness, just scale up your simulator window larger or use real device then you will see it.

Checked your project and even though it have constraint error, it works fine and separator line show up normally.

Upvotes: 1

Related Questions