У меня есть UIDatePicker
, который я печатаю выбранную дату в соответствии с кодом ниже.Тем не менее, он не печатает выбранную дату, только текущую дату.
@objc func setupDiscoverButton() {
let cell = Bundle.main.loadNibNamed("FirstTableViewCell", owner: self, options: nil)?.first as! FirstTableViewCell
// Date
let sessionDate = cell.datePicker.date
print("date: \(sessionDate)")
}
Здесь я делаю определения для моего UIDatePicker
.
func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell {
let cell = Bundle.main.loadNibNamed("FirstTableViewCell", owner: self, options: nil)?.first as! FirstTableViewCell
// Date & time picker
cell.datePicker.minimumDate = Date()
cell.datePicker.timeZone = TimeZone.current
// Discover button
cell.discoverButton.addTarget(self, action: #selector(setupDiscoverButton), for: .touchUpInside)
return cell
}