【发布时间】:2018-07-18 07:27:46
【问题描述】:
描绘一个 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 中的 2-3 内容(价格,数量)wrt 在子 CollectionView 中选择的日期。
【问题讨论】:
-
CollectionView在TableViewCell内部。所以它的delegate也将在那里,您可以直接更新TableViewCell元素。有什么问题? -
我不明白你的tableviewCell的结构。它在集合视图内部,因此您拥有“cellForItem”的类必须是单元类。如果不是,你必须让我们了解你使用什么结构来获得这个(我可以告诉你,你可能把事情搞砸了)
-
我不知道如何更新单元格。现在我能做到了。感谢您回复@Kamran
标签: ios swift uitableview uicollectionview jtapplecalendar