Custom cell not showing in Table View-Xcode

Kamran Ahmed

I have made a custom cell and using its .xib to show in table view. But the this cell is'nt showing in table view.While other custom cells are fine.

Cell Controller:

import UIKit

//Protocol to add action on button click
protocol ChatLinkButtonDelegate: class {
    func chatLinkClick(cell: ChatBankController)
}


class ChatBankController: UITableViewCell {
    @IBOutlet weak var btnseemore: CustomUIButton!
    @IBOutlet weak var year: CustomUILabel!
    @IBOutlet weak var anwser: CustomUILabel!
    @IBOutlet weak var month: CustomUILabel!
    @IBOutlet weak var interest: CustomUILabel!

    var delegate: ChatLinkButtonDelegate?

    override func prepareForReuse() {
        super.prepareForReuse()
        self.delegate = nil
    }
    override func awakeFromNib() {
        super.awakeFromNib()
        // Initialization code
    }
    override func setSelected(_ selected: Bool, animated: Bool) {
        super.setSelected(selected, animated: animated)
        // Configure the view for the selected state
    }

    @IBAction func btnChatLinkClick(_ sender: Any) {
        self.delegate?.chatLinkClick(cell: self)
    }
}

Table View controller to load and show data: Registration:

cell = UINib(nibName: "ChatBank", bundle: nil)
            self.tbChat.register(cell, forCellReuseIdentifier: "ChatBankCell")

Loading cell to tableview:

func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell {

                    let cell:ChatBankController = self.tbChat.dequeueReusableCell(withIdentifier: "ChatBankCell") as! ChatBankController
                    cell.anwser.text="fine"
                    return cell

                    let cell = UITableViewCell()
                    return cell
    }
Jaydip

Register nib file in your view controller.swift file view did load method and set tableview datasource and delegate like

override func viewDidLoad() {
        super.viewDidLoad()

yourTableView.register(UINib.init(nibName:"ProfileTableViewCell" , bundle: nil), forCellReuseIdentifier: "ProfileTableViewCell")

yourTableView.datasource = self
yourTableView.delegate = self

    }

Collected from the Internet

Please contact [email protected] to delete if infringement.

edited at
0

Comments

0 comments
Login to comment

Related

Custom Cell in table view not showing?

Custom table view cell with swift in xcode 6

Custom Card View design in Table View Cell in XCode

Custom Table View Cell as String

Custom Table View Cell with UIView

Table View not working with custom cell

Array values not showing up in custom table cell

XCode 12/Swift 4 Custom Cells not displaying on UI Table Cell View

Table view still showing basic even after making it custom in Xcode 10.1

Custom table view cell image distorting

Custom table view cell: IBOutlet label is nil

iOS 7 custom cell not displaying in table view

RxSwift table view with multiple custom cell types

Custom table view cell with rounded edges

Custom table view cell in Swift, without Storyboard

Custom Table View Cell with a big image and a label

table view cell of custom class returning nil

Using custom XIB in table view cell

The custom cell in the table view does not want to be rounded

Design the custom table view cell programatically

How do I create a custom view in a custom table view cell?

Issue in Showing Collection View in Table View Cell in iOS

Showing and hiding a view only on a specific cell of a table view

Table View Cell class's view showing nil

Accessory of table view cell not showing in iOS 9 and swift

XCode 6 Table View cell running off the screen

Xcode interface builder: Static table view cell font is not being set

Load table view cell with edit options showing by default at initial launch of table view

How to hide a custom class label in a table view cell?