squimer / DatePickerDialog-iOS-Swift

Date picker dialog for iOS
MIT License
580 stars 177 forks source link

Date picker dialogue not showing when called from didSelectRowAtIndexPath delegate function of UITableView. #105

Open jeet10214 opened 4 years ago

jeet10214 commented 4 years ago

HI,

I refferred you example and added the DatePicker component in my project. Now I want to show when the user taps on cell and select the date. However the DatePickerDialogue is not showing. Here is my implementation

let datePicker = DatePickerDialog( textColor: .darkText, buttonColor: .systemBlue, font: UIFont.boldSystemFont(ofSize: 17), showCancelButton: true )

func datePickerTapped() { let currentDate = Date() var dateComponents = DateComponents() dateComponents.month = 6 let threeMonthAgo = Calendar.current.date(byAdding: dateComponents, to: currentDate)

    datePicker.show("Set Activation Date",
                    doneButtonTitle: "Done",
                    cancelButtonTitle: "Cancel",
                    minimumDate: currentDate,
                    maximumDate: threeMonthAgo,
                    datePickerMode: .date) { (date) in
        if let dt = date {
            let formatter = DateFormatter()
            formatter.dateFormat = "MM/dd/yyyy"
            **//want to call an API of the date selected**
        }
    }
}

datePickerTapped() called from DidSelectRowAtIndexPath

jeet10214 commented 4 years ago

Can you tell me what I am doing wrong? I referred your example and the difference is I dont want to add textField.