1

I am creating a UIPicker in Swift and I have two components like one sees in the iPhone timer app.

The problem is that I can not figure out how to get those fixed titles (in the example, hours and min) I have added my fixed words to my row arrays, but they scroll with the numbers and I have to parse the numbers out after the fact. Is there a way to add those fixed titles for the rows to the right of the scrolling wheels?

I would post a picture, but I don't yet have a 10 rating to do this.

Stewart Lynch
  • 875
  • 9
  • 26
  • 1
    You need to create a UILabel for each label you want, then add them to the UIPickerView's view and position them manually. Not that fun; there's more at this answer: http://stackoverflow.com/questions/367471/fixed-labels-in-the-selection-bar-of-a-uipickerview – Nate Cook Oct 21 '14 at 01:06

1 Answers1

-3

You'll want to use the UIPickerViewDelegate method

func pickerView(pickerView: UIPickerView, titleForRow row: Int, forComponent component: Int) -> String! {
    code
}

You can read more about it here:

https://developer.apple.com/library/IOS/documentation/UIKit/Reference/UIPickerViewDelegate_Protocol/index.html

mtaylor
  • 1,130
  • 1
  • 8
  • 6