title: How to use modal views in swift?
body: <p>When adding an account to Mail (in preferences), you get a modal view, like this:
  <img src="https://i.stack.imgur.com/NDfnu.jpg" alt="Example Image, source: kb.xcentric.com/images/ipad12.jpg"></p>
  
  <p>My question is, how do I replicate this programatically? In other words, how do I display a modal UIView over a presenting view?</p>
  
  <p>Here's what I have:</p>
  
  <pre><code>import UIKit
  
  
  class ViewController: UIViewController {
  
  
  
  @IBAction func addCard(sender: AnyObject) {
      var addContact : secondViewController = secondViewController()
      self.modalTransitionStyle = UIModalTransitionStyle.FlipHorizontal 
      self.modalPresentationStyle = .CurrentContext // Display on top of current UIView
      self.presentViewController(addContact, animated: true, completion: nil)
  }
  //Code goes on to do other unrelated things
  </code></pre>
  
  <p>Also, I've done the following:</p>
  
  <ol>
  <li>Created  the View Controller in Interface builder.</li>
  <li>Connected the BarButtonItem "add contact" to the viewcontroller, by control-clicking, dragging to the viewcontroller of the view I want to display, and selecting "modal" in the drop down.</li>
  <li>Set the Class and StoryBoard UI of the presented Viewcontroller to secondViewController.</li>
  </ol>
  
  <p>The expected behavior is that, when the UIBarButton "Add Contact" (which successfully triggers  <code>@IBAction func addCard(sender: AnyObject)</code> in the code above) is pressed, secondViewController is presented as a modal view above the main view.</p>
  
  <p>When I run the code above, I get the error <code>"Use of undeclared type secondViewController"</code></p>
  
  <p>What am I doing wrong?</p>
  
  <p>NOTE: This is a re-ask of <a href="https://stackoverflow.com/questions/25141983/embedding-subview-in-main-view-swift">an earlier question</a> in which I asked a similar, but slightly different question. I checked on <a href="https://meta.stackoverflow.com/questions/268246/appropriate-to-re-ask-questions?noredirect=1#comment75406_268246">meta</a>, and I think it is OK - I don't want to invalidate the answers on the original question, as this is asking something slightly different. Also, in case it helps, I found some <a href="https://stackoverflow.com/questions/849458/transparent-modal-view-on-navigation-controller">similar</a> questions - in obj C. How do I do that in swift?</p>