I am using this library as my floating panel.
i have two view controllers.
in home view controller there is a calendar that select the date. when the date is selected i call for the floatingPanel view controller.
func calendar(_ calendar: FSCalendar, didSelect date: Date, at monthPosition: FSCalendarMonthPosition) {
log.success("date has been selected")/
day = formatter.string(from: date)
// presenting the modal view controller
let fpc = FloatingPanelController()
fpc.delegate = self
guard let floatingPannel = storyboard?.instantiateViewController(withIdentifier: "contentPannel") as? floatingPannel else {
return
}
fpc.set(contentViewController: floatingPannel)
fpc.addPanel(toParent: self)
}
after loading the floating panel i am using the deselect method in the calendar to dismiss the presented modal view.
func calendar(_ calendar: FSCalendar, didDeselect date: Date, at monthPosition: FSCalendarMonthPosition) {
// dismiss the current modal view
}
i want to dismiss the current modal view from inside this function. is there any way i can do it.
you need to declare fpc as an instance property of your view controller.
let fpc = FloatingPanelController()
then
func calendar(_ calendar: FSCalendar, didSelect date: Date, at monthPosition: FSCalendarMonthPosition) {
day = formatter.string(from: date)
guard let floatingPannel = storyboard?.instantiateViewController(withIdentifier: "contentPanel") as? floatingPannel else {
return
}
fpc.set(contentViewController: floatingPannel)
fpc.addPanel(toParent: self)
}
you can dismiss the view from
func calendar(_ calendar: FSCalendar, didDeselect date: Date, at monthPosition: FSCalendarMonthPosition) {
fpc.dismiss(animated: true, completion: nil)
}