1

在此处输入图像描述

描绘一个 tableViewCell 的图像。在一个 tableViewCell 里面有一些内容和一个 CollectionView(显示日期的灰色区域)。根据集合视图中的日期及其滚动,我必须显示年份和月份(“2018 年 12 月”:图像中是静态的)。

这是我的 JTAppleCalender cellForItemAt 方法:

   func calendar(_ calendar: JTAppleCalendarView, cellForItemAt date: Date, cellState: CellState, indexPath: IndexPath) -> JTAppleCell {

        let cell = calendar.dequeueReusableJTAppleCell(withReuseIdentifier: "CalenderCell", for: indexPath) as! CalenderCell

        cell.lblDate.text = cellState.text
        formatter.dateFormat = "EEE"
        cell.lblDay.text = formatter.string(from: cellState.date)

        formatter.dateFormat = "MMMM YYYY"
        print(formatter.string(from: cellState.date))

        formatter.dateFormat = "dd-MM-yyyy"
        print(formatter.string(from: cellState.date))

        if(pickup_dates .contains(formatter.string(from: cellState.date))){
            let index = pickup_dates.index(of: formatter.string(from: cellState.date))
            let dictinfoDelivery = self.infoDelivery.object(at: index) as! NSDictionary
            cell.lblPrice.text = dictinfoDelivery .value(forKey: "total_price_format") as? String
            cell.isUserInteractionEnabled = true
        }
        else{
            cell.lblPrice.text = ""
            cell.isUserInteractionEnabled = false
        }

        return cell
    }

我正在尝试从该方法内部访问 tableView label("December 2018") 但无法这样做。如何从子 collectionViewCell 访问这个 TableViewCell 标签?我的要求是更改 tableViewCell(价格,数量)wrt 在子 CollectionView 中选择的日期中的 2-3 内容。

4

1 回答 1

1

请试试这个

  guard  let lbl = (self.yourTableView.cellForRow(at: [NSIndexPath(row: 0, section: 0) as IndexPath]) as! yourCellNameInTableView).labelName else {
        return
   }
  lbl.text = "Your text"

请传递您的行号和节号。它可能对你有帮助。谢谢

于 2018-07-18T07:48:01.570 回答