-1

I have a UITableView with a UITableViewCell with a textview and imageview inside it

In swift file I have defined

class NotificationCell: UITableViewCell {
@IBOutlet weak var notificationAvatarImage: UIImageView!
@IBOutlet weak var notificationText: UITextView!


override func awakeFromNib() {
    notificationAvatarImage.clipsToBounds = true
    notificationAvatarImage.contentMode = .scaleAspectFill
}
}

I am unable to connect the imageView & textview in storyboard to IBOutlet notificationAvatarImage ... in NotificationCell. How do I do this?

Iam loading the table as

guard let notificationCell = tableView.dequeueReusableCell(withIdentifier: "Cell") as? NotificationCell else {
        fatalError("Error getting cell")
}
Anoop Krishnan
  • 331
  • 3
  • 14

1 Answers1

0

First of all use the UITableViewDataSource delegate of tableview to load the tableviewcell.

 func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell
{
    let cell = tableView.dequeueReusableCell(withIdentifier: "Cell") as! NotificationCell
    return cell
}

Using Storyboard

Now create the UITableViewCell in your storyboard and set the Class of that UITableViewCell to NotificationCell and then right click on your imageview and textview of the tableviewcell in storyboard and assign it to the @IBOutlet of NotificationCell class you wrote in Swift

Samarth Kejriwal
  • 1,168
  • 2
  • 15
  • 30