Using a UIPickerView as input for another control

August 30, 2019 · 1 min read

The Problem

You want to offer a pre-selected list of options to a user. This helps protect the content that gets entered into another control like a label or a text field or maybe even just an entry to be stored in a database.

The Solution

So the solution is actually very straight forward, give them a picker that they can scroll to find the desired selection in. As that value changes, you can take that selection and put it somewhere else in your application. In this example, we change the value of a label.

The Steps

  1. Place the UIPickerView and Label on the storyboard.
  2. Make the view controller the delegate and data source for the UIPickerView.
  3. Add the needed protocols for acting as a delegate.
  4. Add an outlet for the label so we can access it’s value in code.
  5. Provide data to the UIPickerView.
  6. Make use of the pickerView:didSelectRow:inComponent: to detect changes and update the label.

The Video




Peter Witham
Peter Witham

Web and Mobile Software Maker, Photographer and Podcaster. I live and breath creativity.
I'd love for you to connect with me via Twitter or if you are a photo person like myself, Instagram.



Related Reads
03-27-2020 Live Stream Highlights

I needed to fix a bug where inserting a pre-coded string was not respecting the attributed string di...


March 28, 2020 · 1 min read

Related Reads
Podcast Season 1 Episode 20 - iPad gets a cursor

It happened, maybe it was inevitable despite Apple’s best effort to say we don’t need it. But the iP...


March 23, 2020 · 1 min read

Related Reads
How to use GitHub with Xcode 11

Xcode 11 and GitHub have come a long way in their relationship, we can now work directly with GitHub...


March 22, 2020 · 1 min read

Related Reads
Live Stream Recording - macOS App Development

As I continue to work on my application I created for personal use, I have a bug that I need to reso...


March 21, 2020 · 1 min read

Related Reads
Using SF Symbols in macOS Applications

SF Symbols is a great library, but it does not play well currently with macOS development. So here i...


March 19, 2020 · 1 min read

Related Reads
Setting NSTextView Font Size Using Swift

When setting the font size of an NSTextView things can get a bit weird with the Attributes Inspector...


March 18, 2020 · 2 min read