At some point you will want to present a list of items to your users and prompt them to select one. Whilst a spinner is an OK option I prefer the Alert Controller. It’s simple to use and doesn’t take up any screen space until you need it.

1. Create a new UIAlertController and specify that this is a preferred style of “.actionSheet”. Action sheet implies we’re going to present a whole bunch of options:

2. Add some actions to the alert:

Note that you can add as many actions as you like.

3. Finally you need to show the action. This is usually performed in your view controller class (hence the “self” ):

Optionally you can specify a further action once the alert has been shown.

The alert controller is very useful when requesting your user to select from a medium sized list of items.

How to Show an Alert with a List of Items in Swift 4 and iOS 12
Tagged on:     

One thought on “How to Show an Alert with a List of Items in Swift 4 and iOS 12

  • June 30, 2017 at 4:22 pm
    Permalink

    Works for me! Tks! 🙂

    Reply

Leave a Reply

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

This site uses Akismet to reduce spam. Learn how your comment data is processed.

Share This

Exhausted by your 9 - 5?

Would you prefer to work for half the time and earn double? The first step to your freedom is understanding how apps make money. Simply enter your email below and I will send you a free PDF describing the process.

If you're serious about improving your life then do not miss this opportunity.


You have subscribed! Please check your email to confirm this subscription and to receive your item!