0

I have a custom UITableViewCell (with .xib file and custom class inherit from UITableViewCell, which have four labels). I have implemented the constraints of the contents properly, and this is the aspect in storyboard.

enter image description here

But when I run the app in simulator, the result is this.

enter image description here

It seems the contents goes to point 0,0 of x,y axis, but I can't figure out what happens.

I tried this solution, but doesn't work for me.

My app is made with storyboard. I have, in a ViewController, a UITableView (default) and I created a UITableViewCell customized (called StatementTableViewCell), which I register via code inside viewDidLoad's viewController method (tableView.registerNib(.....)).

override func viewDidLoad() {
        super.viewDidLoad()

        // I've put the name of identifier and the class as the same.        
        self.tableView.register(UINib(nibName: IDENTIFIERS.TABLE_VIEW_CELL, bundle: nil), forCellReuseIdentifier: IDENTIFIERS.TABLE_VIEW_CELL)
        
        // remainded code
    }

Someone knows how to solve this and please could help me? Thanks!

matt
  • 515,959
  • 87
  • 875
  • 1,141

1 Answers1

0

Okay, well, you didn't tell the truth in your question about how this is laid out. You have two vertical stack views inside a horizontal stack view. So:

  • Change the outer stack view's distribution to Fill Equally and zero spacing (or maybe 8, as Don Mag suggests).

  • Change the labels' number of lines to 0.

Bingo. You do still have some ambiguity issues due to the content hugging of the labels, but you can take care of that later.

enter image description here

matt
  • 515,959
  • 87
  • 875
  • 1,141