1

enter image description here

Image Depicting One tableViewCell. Inside One tableViewCell there is some content and One CollectionView(Gray color area showing dates). Depending on dates in collection view and their scrolling I have to show Year and Month("December 2018" : It is static in image).

This is my JTAppleCalender cellForItemAt method :

   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
    }

I am trying to access tableView label("December 2018") from inside of this method but was unable to do so. How to access this TableViewCell label from child collectionViewCell? My Requirement is to Change 2-3 contents in tableViewCell (Price,quantity) wrt Date Selected in Child CollectionView.

Shivam Tripathi
  • 1,405
  • 3
  • 19
  • 37
  • 1
    `CollectionView` is inside `TableViewCell`. so its `delegate` will also be there and you can directly update the `TableViewCell` elements. What is the issue? – Kamran Jul 18 '18 at 08:07
  • I don't understand the structure of your tableviewCell. It have inside the collection view, so the class where you have the "cellForItem" must be cell class. If not you must let us understand what structure you used to obtain this (and I can say to you that you have probably messed up the things) – MarkWarriors Jul 18 '18 at 08:38
  • 1
    I was not aware about how to update the cells. Now I was able to do. Thanks for replying @Kamran – Shivam Tripathi Jul 19 '18 at 07:55

1 Answers1

1

please try this

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

Please pass your row number and section number. It may helps to you.Thanks you

Sanjukta
  • 1,057
  • 6
  • 16