Can anyone help me how to make the UIPickerView displays the first row’s value after the last row’s value, just like the UIDatePicker where after 12 the 1 will follow.
Thanks
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
I don’t think its possible to really make it circular, but you can fake it.
You can change the number of strings in pickerData and it will still work fine. The selected row selects the “first” value closest to the middle. row%[pickerData count] returns the following assuming there are 3 NSStrings in pickerData:
It will just cycle 0 through the length of the array. The confusing stuff in viewDidLoad just picks a value as close to the middle as possible using the index of the item of the array you provide in selectedItem. There is no performance hit or memory leak, all you have allocated is the single array. Whenever you access their selected choice, use ([localPicker selectedRowInComponent:0]%[pickerData count]). If there’s something you don’t understand or something I missed, please comment.
Hope this helped!