title: UIPopoverController getting crashing in iPhone in swift
body: <p>I am working with the UIPopViewController.I have a BarButton with add option.If I click on the ‘+’ popup has to come.It is working fine when I gave connection in storyBoard.But If I am calling using the code,it is not working.It is crashing..My code is like this..</p>
  
  <pre><code>@IBAction func addingData(sender: AnyObject) {
  
      let storyboard = UIStoryboard(name: "Main", bundle: nil)
      let playerInformationViewController = storyboard.instantiateViewControllerWithIdentifier("PopView") as? PopView
      playerInformationViewController!.modalPresentationStyle = .Popover
      playerInformationViewController!.preferredContentSize = CGSizeMake(300, 300)
      playerInformationViewController!.delegate = self
  
      let popoverPresentationViewController = playerInformationViewController!.popoverPresentationController
      popoverPresentationViewController?.permittedArrowDirections = .Any    
      popoverPresentationViewController?.delegate = self    
      popoverPresentationController?.barButtonItem = sender as? UIBarButtonItem
  
      presentViewController(playerInformationViewController!, animated: true, completion: nil)
  }
  
  override func prepareForSegue(segue: UIStoryboardSegue, sender: AnyObject?) {
      if segue.identifier == "test" {
          let popoverViewController = segue.destinationViewController 
          popoverViewController.modalPresentationStyle = UIModalPresentationStyle.Popover
          popoverViewController.popoverPresentationController!.delegate = self
      }
  }
  </code></pre>
  
  <p>The error Message I am getting is …</p>
  
  <blockquote>
    <p>UIPopoverPresentationController: 0x7fdda8cd4ad0>) should have a non-nil    sourceView or barButtonItem set before the presentation occurs.’**</p>
  </blockquote>
  
  <p>Can anyone tell me what mistake I did.Please clarify my doubt.</p>
  
  <p>Thanks in Advance.</p>