i have implemented XLPagerTabStrip library in my app, Now in my Container VC i have a calendar on which when i click i call a delegate function which take the value of my selected date. I have 3 ChildVC name AcceptedBookingVC, PendingBookingVC and HistoryBookingVC. Now i want to pass the selectedDate to the VC which is open currently. How i can pass that? I have used delegate but it isn't passing my data. This is my code,

protocol BookingContainerDelegate {

func selectedDate(selectedDate:String)

func calendar(_ calendar: FSCalendar, didSelect date: Date, at monthPosition: FSCalendarMonthPosition) {

    let selected = calendar.selectedDate

    let dateFormatter1: DateFormatter = DateFormatter()
    dateFormatter1.dateFormat = "yyyy-MM-dd HH:mm:ss.SSS"
    dateFormatter1.dateFormat = "yyyy-MM-dd"
    print("\(dateFormatter1.string(from: selected!))")
    selectDate = dateFormatter1.string(from: selected!)
    dateDelegate?.selectedDate(selectedDate: dateFormatter1.string(from: selected!))
    self.popViewTopConstraint.constant = -300
    popUpShowing = false

    UIView.animate(withDuration: 0.3) {

This is the code for XLPager when i'm calling child vc's in Container VC,

 override func viewControllers(for pagerTabStripController: PagerTabStripViewController) -> [UIViewController] {
    let child1 = UIStoryboard().loadAcceptedBookingVC()
    child1.dateDelegate = self
    child1.selectDate = selectDate
    child1.itemInfo = "Accepted"

    let child2 = UIStoryboard().loadPendingBookingVC()
    child2.selectDate = selectDate
    child2.itemInfo = "Pending"

    let child3 = UIStoryboard().loadHistoryBookingVC()
    child3.selectDate = selectDate
    child3.itemInfo = " History"

    return [child1,child2,child3]

Here is Child VC i'm calling my delegate but it isn't have a value,

extension AcceptedBookingVC : BookingContainerDelegate

{ func selectedDate(selectedDate: String) { print(selectedDate) date = selectedDate } }

My screen looks like this when i select the date, enter image description here

0 Answers