在callData中,将电话号码另存为callBtnAction,您可以通过选择器方法将其取回。
public func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell{
let cellIdendifier: String = "CallDataCell"
let cellData = arrayOfCallData[indexPath.row]
let cell : UITableViewCell = tableView.dequeueReusableCell(withIdentifier: cellIdendifier, for: indexPath)
let button = UIButton.init()
button.frame = CGRect.zero //Set your frame here
button.setTitle(cellData.callBtnText, for: UIControlState.normal)
button.tag = indexPath.row
button.addTarget(self, action: Selector(("buttonClicked:")), for: UIControlEvents.touchUpInside)
cell.addSubview(button)
return cell
}
func buttonClicked(sender:UIButton) {
let selectedRow = sender.tag
let callData = arrayOfCallData[selectedRow]
let action = callData.callBtnAction
print(action)
}