I have array of posts in tableView and there are posts have an image and another no

I have an array of posts, there are posts have an image and there have not, how I configure that in tableViewCell


my cell is:


import UIKit

class NotesCell: UITableViewCell {
    @IBOutlet weak var contentNote: UILabel!
    @IBOutlet weak var dateOfNote: UILabel!
    @IBOutlet weak var imageNote: UIImageView! 
}

Replies

If you want just not to show the image, set its image to nil


imageNote.image = nil


You may also adjust the constraints programmatically (define an IBOutlet for each constraint you need to change), if you need to change the layout when there is no image.


If you want a different cell layout, you can also create another tableViewCell class and its xib without imageNote.