Git Product home page Git Product logo

Comments (10)

ehmjaysee avatar ehmjaysee commented on August 26, 2024 6
    if #available(iOS 13.4, *) {
        datePicker.preferredDatePickerStyle = .wheels
    }

from andyibanez-com.

DoctorShredd avatar DoctorShredd commented on August 26, 2024 1

Ive implemented a UIDatePicker in an app written in Swift. I can create an @action to trigger when the date changes unless the user uses the arrows in the upper right hand corner to change the month... I cant figure out how to capture that event. Any thoughts?

from andyibanez-com.

Mwangi avatar Mwangi commented on August 26, 2024 1

Let me assist @DoctorShredd...

You can approach it in a different way. For instance use what you were using before then check the iOS version...

Something like..

@objc func StartDateSelection(){

    if #available(iOS 13.4, *) {
        startdatePicker.isHidden = false
        tfStartDate.isHidden = true
        startdatePicker.datePickerMode = .date
        startdatePicker.preferredDatePickerStyle = UIDatePickerStyle.compact
        startdatePicker.addTarget(self, action: #selector(self.startDateChanged), for: .allEvents)
    }
    else{
        DatePickerDialog().show("From Date", doneButtonTitle: "Done", cancelButtonTitle: "Cancel", datePickerMode: .date) {
            (date) -> Void in
            if let dt = date {
                let formatter = DateFormatter()
                formatter.dateFormat = "dd/MM/yyyy"
                self.tfStartDate.text = formatter.string(from: dt)
            }
        }
    }
}

@objc func startDateChanged(){
    let formatter = DateFormatter()
    formatter.dateFormat = "dd/MM/yyyy"
    self.tfStartDate.text = formatter.string(from: (startdatePicker?.date)!)
}

from andyibanez-com.

Pratik948 avatar Pratik948 commented on August 26, 2024

Great Article. Not a question but just something to point out. Your post is displaying date of future (or are you a time traveller?). Today its 9th of July, 202 but your post is of 27th of July, 2020 :D
Imgur

from andyibanez-com.

AndyIbanez avatar AndyIbanez commented on August 26, 2024

Great Article. Not a question but just something to point out. Your post is displaying date of future (or are you a time traveller?). Today its 9th of July, 202 but your post is of 27th of July, 2020 :D
Imgur

Thanks, I have fixed the date now.

from andyibanez-com.

ehmjaysee avatar ehmjaysee commented on August 26, 2024

Might be helpful to point out that you cannot change the .datePickerStyle directly, instead you must set .preferredDatePickerStyle

from andyibanez-com.

AndyIbanez avatar AndyIbanez commented on August 26, 2024

Thanks for bringing that to my attention. I will verify this and update the article accordingly.

from andyibanez-com.

w-i-n-s avatar w-i-n-s commented on August 26, 2024

Thank you.

from andyibanez-com.

DoctorShredd avatar DoctorShredd commented on August 26, 2024

Thanks, I'll give it a try!

from andyibanez-com.

andreyluiz avatar andreyluiz commented on August 26, 2024

Can we force the wheels picker on Safari by any chance?

from andyibanez-com.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.