Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Date Picker not working in IOS 8.2 swift 3 #334

Closed
manishpurplefront opened this issue Mar 21, 2017 · 2 comments
Closed

Date Picker not working in IOS 8.2 swift 3 #334

manishpurplefront opened this issue Mar 21, 2017 · 2 comments

Comments

@manishpurplefront
Copy link

manishpurplefront commented Mar 21, 2017

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
Copy link

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

@skywinder
Copy link
Owner

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants