jo1995
jo1995

Reputation: 414

TableViewCell will be not displayed completely

I want to display the following default cell if no posts are available:

enter image description here

This time, my cell will be displayed like that:

enter image description here

I already set the following codelines in viewDidLoad:

tableView.estimatedRowHeight = 150
tableView.rowHeight = UITableView.automaticDimension

In my cellForRowAt I have set the following lines:

func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell {
    switch self.postArray.count {

    case 0:
        let cell = tableView.dequeueReusableCell(withIdentifier: "KeineBeiträgeVorhanden")!
        return cell

    default:

    let cell = tableView.dequeueReusableCell(withIdentifier: "DiscoveryCollectionViewCell", for: indexPath) as! DiscoveryCollectionViewCell

But my TableViewCell is not displayed in the right size. Thanks in advance for your help!

Merry Christmas to all!!!

Upvotes: 1

Views: 30

Answers (1)

Shehata Gamal
Shehata Gamal

Reputation: 100533

Image constraints

( top , centerX ) => to superView , width , height

label constraints

top => to image , ( leading , trailing , bottom ) => to superView 

and .lines = 0

Upvotes: 2

Related Questions