iOS Tutorials: PickerView on UIAlertController

Have you ever thought of implementing PickerView into UIAlertcontroller? Well, I have and I’ve decided to make a simple tutorial on this as I could possibly see that it could be useful to anyone that is seeking for this method.

As always, create your new project and give it a preferred name for this project.

The only object that we are using right here is Button. So grab a button and put it on the Main.storyboard and connect it to the ViewController.swift with an action type.

We are going do some codings here. First, lets create a an array that contains all the type of cars. Then let’s add UIPickerViewDelegate and UIPickerViewDataSource as we will be using PickerView in the AlertController. However, since we did not use any PickerView object, lets create our own object. Lastly, create a variable that named typeValue

Make sure you implement some of the pickerview functionality.

Lastly, this would be the action of the button which will then show a PickerView. As you can see, the way this is done is by creating an UIAlertController with several black space contain within the message hoping to create some space for the PickerView. Then we will create the size of the PickerView. With this, we could easily add the PickerView onto the AlertController. You could add most functionality that include Cancel or Ok.

At the end, the result would be like below:

The GitHub link could be found here

  • Article By :
    Founder of DaddyCoding. Studied Computer Science, Information System and Information Technology at BYU-Hawaii. Currently spending most of my time researching and learning on helping to expose making iOS apps.

Random Posts

One thought on “iOS Tutorials: PickerView on UIAlertController

Leave a Reply

Your email address will not be published. Required fields are marked *

*
*