4

I added UIDatePicker in my storyboard, and set mode to CountDownTimer. It shows hours and minutes only, but what i need is minutes and seconds mode. I don't need hour column, need minute and seconds columns. I try to change interval, but it's minimum value is 1 minute. Is it possible? How can I do this?

ttotto
  • 826
  • 3
  • 13
  • 31

1 Answers1

2

You can create a datasource for you minute-seconds picker. It has two Components: minute and seconds. You have to implement some methods in UIPickerViewDelegate and UIPickerViewDataSource Protocols.

Apple's sample code UICatalog.app is for your reference. You can find there is a sample for how to create a customized picker.

lu yuan
  • 7,207
  • 9
  • 44
  • 78
  • Is that mean I should use UIPickerview, not UIDatePicker? – ttotto Jul 17 '12 at 14:02
  • @ttotto yes, as the datePickerMode does not have a type you want. – lu yuan Jul 17 '12 at 15:00
  • thanks, then I want to add "minute" and "second" on the selection bar of the pickerview. Do you know how can I do this? – ttotto Jul 17 '12 at 16:32
  • @ttotto take a look at the sample how to create a custom picker. – lu yuan Jul 17 '12 at 17:43
  • Of course, I reviewed the code and make it, but there is no that feature. Do you know selection bar of the picker control? And have you ever seen the selection bar of the UIDatePikcer in UIDateCountDownMode? If you see it, you can find the "Hour" and "Minute" string on the selection bar. – ttotto Jul 18 '12 at 01:05
  • @ttotto Is UIDateCountDownMode what you need? I don't think so. As I never use that mode, but only read the doc for it. What you have to do is to custom your own picker. The code in the sample is not exactly what you need, but you can refer to it and learn how to implement the methods in UIPickerViewDelegate and UIPickerViewDataSource Protocols. – lu yuan Jul 18 '12 at 03:28
  • thanks. you don't understand me yet. I found a solution at the http://stackoverflow.com/questions/367471/fixed-labels-in-the-selection-bar-of-a-uipickerview. – ttotto Jul 18 '12 at 07:10