Created
June 30, 2017 05:20
-
-
Save TechMaster/b51c759ef72fff37bcdef5aef8bedc5b to your computer and use it in GitHub Desktop.
ShowAlertView.swift
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| // | |
| // ViewController.swift | |
| // DisplayAlert | |
| // | |
| // Created by cuong on 6/30/17. | |
| // Copyright © 2017 Techmaster. All rights reserved. | |
| // | |
| import UIKit | |
| class ViewController: UIViewController { | |
| override func viewDidLoad() { | |
| super.viewDidLoad() | |
| } | |
| override func viewDidAppear(_ animated: Bool) { | |
| super.viewDidAppear(animated); | |
| self.showAlert() | |
| } | |
| func showAlert() { | |
| let actionSheetController: UIAlertController = UIAlertController(title: "Action Sheet", message: "Swiftly Now! Choose an option!", preferredStyle: .actionSheet) | |
| //Create and add the Cancel action | |
| let cancelAction: UIAlertAction = UIAlertAction(title: "Cancel", style: .cancel) { action -> Void in | |
| //Just dismiss the action sheet | |
| } | |
| actionSheetController.addAction(cancelAction) | |
| //Create and add first option action | |
| let takePictureAction: UIAlertAction = UIAlertAction(title: "Take Picture", style: .default) { action -> Void in | |
| //Code for launching the camera goes here | |
| } | |
| actionSheetController.addAction(takePictureAction) | |
| //Create and add a second option action | |
| let choosePictureAction: UIAlertAction = UIAlertAction(title: "Choose From Camera Roll", style: .default) { action -> Void in | |
| //Code for picking from camera roll goes here | |
| } | |
| actionSheetController.addAction(choosePictureAction) | |
| //Present the AlertController | |
| self.present(actionSheetController, animated: true, completion: nil) | |
| } | |
| } | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment