Referance Link that I have used
Here is my code
class ViewController: UITableViewController{
override func viewDidLoad() {
super.viewDidLoad()
tableView.allowsMultipleSelectionDuringEditing = true
tableView.setEditing(true, animated: false)
}
override func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell {
let cell = tableView.dequeueReusableCell(withIdentifier: "cell", for: indexPath)
cell.textLabel?.text = "\(indexPath.row)"
return cell
}
override func tableView(_ tableView: UITableView, numberOfRowsInSection section: Int) -> Int {
return 10
}
}
It was Work fine for the default
UITableViewCell
. But if I have do the same thing with CustomUITableViewCell
then selection is not worling
Code with Custom Cell
class ViewController: UITableViewController{
override func viewDidLoad() {
super.viewDidLoad()
tableView.allowsMultipleSelectionDuringEditing = true
tableView.setEditing(true, animated: false)
}
override func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell {
let cell = tableView.dequeueReusableCell(withIdentifier: "customcell", for: indexPath) as! ProductTblCell
cell.lblProductTitle?.text = "\(indexPath.row)"
return cell
}
override func tableView(_ tableView: UITableView, numberOfRowsInSection section: Int) -> Int {
return 10
}
}
ProductTblCell Calss
class ProductTblCell: UITableViewCell {
@IBOutlet weak var lblProductTitle: UILabel!
}
Can you please someone tell me what's going Wrong? Thanks in advance
Output