skywinder / ActionSheetPicker-3.0

Quickly reproduce the dropdown UIPickerView / ActionSheet functionality on iOS.
http://skywinder.github.io/ActionSheetPicker-3.0
BSD 3-Clause "New" or "Revised" License
3.4k stars 740 forks source link

Date Picker not working in IOS 8.2 swift 3 #334

Closed manishpurplefront closed 6 years ago

manishpurplefront commented 7 years ago

Here is the code executed on UIBarbuttonItem but gives error on bar button click.

 @IBAction func calender_date(_ sender: UIBarButtonItem) {

    let datePicker = ActionSheetDatePicker(title: "Date:", datePickerMode: UIDatePickerMode.date, selectedDate: NSDate() as Date!, doneBlock: {
        picker, value, index in

        print("value = \(value)")
        print("index = \(index)")
        print("picker = \(picker)")
        return
    }, cancel: { ActionStringCancelBlock in return }, origin: (sender as AnyObject).superview!?.superview)

    let secondsInWeek: TimeInterval = 7 * 24 * 60 * 60;
    datePicker?.minimumDate = NSDate(timeInterval: -secondsInWeek, since: NSDate() as Date) as Date!
    datePicker?.maximumDate = NSDate(timeInterval: secondsInWeek, since: NSDate() as Date) as Date!
    datePicker?.show()
}

The Error is this

fatal error: unexpectedly found nil while unwrapping an Optional value

This line is highlitted in red

 }, cancel: { ActionStringCancelBlock in return }, origin: (sender as AnyObject).superview!?.superview)
ssuchanowski commented 7 years ago

What's going on with the !? here (sender as AnyObject).superview!?.superview Did you check if this isn't causing the issue?

skywinder commented 6 years ago

There is no recent activity for this issue. Seems this issue is not valid anymore. Feel free to reopen it, if I'm wrong.