Reputation: 49
I’m so stuck with creating various cell types in my Table View.
This is my way to do it.
Create a TableView and put a prototype cell and give it a identifier(let’s say “cell1” here)
Create a TableViewCell file with xib file and give them the same identifier as I gave to the prototype cell(“cell1”)
In the xib file, I put one imageView and label to the cell. Then set some constrains to them. Also connected them to the TableView cell file as outlets.
In the TableViewCell file, I added those two imageView and label as subview to self.
In the TableViewController file, I registered the Nib.
In the TableViewController file, I set a text to the label I created in the xib file(in the “cellForRowAt” method)
I created a custom cell file with xib file and set a imageView and Label to the cell in the xib file. Then I gave an sample image to the image View and set some constrains to the imageView and label.
And then I registered my Nib into my TableViewComtroller file in View did load method.
Finally, the custom cell I created in my xib file appears on my TableView BUT the constrains I set up in the xib file completely disappears. It seems like the imageView and label are located kind of randomly. And also the sample image I set up for the imageView doesn’t appear neither.
Could someone possibly help me out please?
Upvotes: 0
Views: 170
Reputation: 4855
As you had not provided any screenshot I can refer you a reference here with this link I had used TableView With sections in which Header cell is From Xib
I didn't faced such issue about my Constraints You can check this file as reference and hope you get where you are mistaking , if still you find issue please Comment
https://github.com/RockinGarg/Expandable-TableView-.git
Upvotes: 1