Comments (10)
if #available(iOS 13.4, *) {
datePicker.preferredDatePickerStyle = .wheels
}
from andyibanez-com.
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.
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.
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
from andyibanez-com.
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
Thanks, I have fixed the date now.
from andyibanez-com.
Might be helpful to point out that you cannot change the .datePickerStyle directly, instead you must set .preferredDatePickerStyle
from andyibanez-com.
Thanks for bringing that to my attention. I will verify this and update the article accordingly.
from andyibanez-com.
Thank you.
from andyibanez-com.
Thanks, I'll give it a try!
from andyibanez-com.
Can we force the wheels picker on Safari by any chance?
from andyibanez-com.
Related Issues (20)
- posts/understanding-async-await-in-swift/ HOT 13
- posts/modern-concurrency-in-swift-introduction/ HOT 5
- posts/structured-concurrency-in-swift-using-async-let/ HOT 7
- posts/converting-closure-based-code-into-async-await-in-swift/ HOT 10
- posts/integrating-face-id-touch-id-swiftui/ HOT 5
- posts/introduction-to-unstructured-concurrency-in-swift/ HOT 3
- posts/the-mysterious-codablewithconfiguration-protocol/ HOT 2
- posts/strategies-asking-users-rate-your-app/ HOT 2
- posts/using-asyncsequence-in-swift/ HOT 2
- posts/parametrized-shortcuts/ HOT 1
- posts/modern-swift-concurrency-summary-cheatsheet-thanks/ HOT 1
- posts/speech-recognition-sfspeechrecognizer/ HOT 1
- posts/quick-tip-custom-debug-printing-customdebugstringconvertible-swift/ HOT 1
- posts/modern-concurrency-apple-platforms-now-available/ HOT 3
- posts/mainactor-and-global-actors-in-swift/ HOT 1
- posts/filtering-arrays-nspredicate/ HOT 1
- posts/ten-years-and-over-100-articles-later/ HOT 1
- posts/getting-started-app-store-connect-api/ HOT 5
- posts/a-short-guide-localization-apple-platforms/ HOT 1
- posts/swift-print-in-depth/ HOT 3
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
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.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from andyibanez-com.