I need to perform a Popover segue when user touches a cell in a dynamic TableView. But when I try to do this with this code:
- (void)tableView:(UITableView *
I have made this in the simplest way:
then in table view cell's button touch make:
private func presentCleaningDateDatePicker(from button: UIButton) {
performSegue(withIdentifier: "Date Picker Popover Segue", sender: button)
}
and implement prepare(for segue) method
override func prepare(for segue: UIStoryboardSegue, sender: Any?) {
if let identifier = segue.identifier {
switch identifier {
case "Date Picker Popover Segue":
if let vc = segue.destination as? DatePickerViewController {
if let ppc = vc.popoverPresentationController {
ppc.sourceView = sender as! UIButton
ppc.sourceRect = (sender as! UIButton).frame
ppc.delegate = vc
vc.minimumDate = Date()
vc.maximumDate = Date().addMonth(n: 3)
vc.delegate = self
}
}
default:
break
}
}
}