Pass variable to custom UITableViewCell from UIViewController

前端 未结 4 737
死守一世寂寞
死守一世寂寞 2021-01-20 20:59

Here is how I use my custom UITableViewCell RunningTableViewCell inside UIViewController:

func tableView(tableView: UITableView, ce         


        
4条回答
  •  走了就别回头了
    2021-01-20 21:38

    You can resolve this issue by call custom method in your cell like,

    inside UIViewController:

    //.......
    
    cell.isTop = false
    if(indexPath.row == 0){
        cell.isTop = true
    }
    
    cell.isBottom = false
    if(indexPath.row == myArray.count-1){
        cell.isBottom = true
    }
    
    cell.UpdateViews()
    
    return cell
    }
    

    inside TableViewCell:

    //@IBOutlet ...
    
    var isTop: Bool?
    var isBottom: Bool?
    
    func updateViews() {
      print("result: \(self.isTop) \(self.isBottom)")
    }
    

    Good luck!

提交回复
热议问题