Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How can i create a year only Picker View in Swift [duplicate]

first time posting here, so hope i am doing this right.

I am trying to create a picker or date picker that allows me to display only the years from 1900 to this year(2015).
so it should looking something like:

" Year house was built: picker of years between 1900-2015 "

The only way i can think to do this is with a Picker View and an array of 115 values and i don't believe this is the right way.

Any help or guidance would be greatly appreciated and apologies if i am using the website wrongly.

like image 576
Matthew Ghent Avatar asked Dec 07 '25 21:12

Matthew Ghent


1 Answers

Simply use a UIPickerView and a simple for-loop statement to build the years and fill the UIPickerView

for (var i=1899; i<2015; i++) 
array[i] = i + 1
like image 136
r4id4 Avatar answered Dec 09 '25 15:12

r4id4



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!