Reputation: 414
I want to display the following default cell if no posts are available:
This time, my cell will be displayed like that:
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
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