Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

[UILabel length]: unrecognized selector sent to instance after using AutoLayout

I have a table view with custom cells which contains several views piled one on top of the other and one of them is instantiated using a XIB file. In that XIB file, I have a UIImage and two UILabels I've encapsulated in a UIView. I've figured out already this is the source of my exception but I don't understand why. If I set hard-coded (instead of relative) constraints on the labels, i.e. fixed width and height it works.

I'm attaching a print screen that shows the constraints. Notice that in most constraints the constant = 0 otherwise it's stated in parentheses on the document outline. Also, the label's heights are 0.5 of their container's height.

Any clue to why it crashes?

like image 661
Guy Kahlon Avatar asked Feb 23 '15 11:02

Guy Kahlon


1 Answers

Just encountered and fixed this problem for me. We had a UILabel in a UIView, and that UILabel's outlet was called title. When we asked our cell to 'layoutIfNeeded', we got the UILabel length exception. The -viewForBaselineLayout method on UIView mentions the word title.

We changed the outlet so it was called "cellTitle" (anything but "title") and this crash goes away.

Can you try changing your outlet name?

like image 89
r3c0d3 Avatar answered Oct 26 '22 15:10

r3c0d3