我正在尝试在点击的行下方显示日期选择器(类似于图片中显示的那个)
override func tableView(_ tableView: UITableView, numberOfRowsInSection section: Int) -> Int {
return 2
}
override func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell {
let cell = Bundle.main.loadNibNamed("DailyTimesTableViewCell", owner: self, options: nil)?.first as! DailyTimesTableViewCell
return cell
}
如何在所选行的下方插入datePickerCell(如图所示),感谢您的帮助。
override func tableView(_ tableView: UITableView, didSelectRowAt indexPath: IndexPath) {
// Here I am trying to insert datePickerCell below the selected row (as shown in the image)
let datePickerCell = Bundle.main.loadNibNamed("DatePickerTableViewCell", owner: self, options: nil)?.first as! DatePickerTableViewCell
var rowNumber = indexPath.row + 1
var newIndexPath = IndexPath()
newIndexPath.row = rowNumber
tableView.insertRows(at: [newIndexPath], with: .automatic)
}