title: iOS UIDocumentInteractionController LaunchServices: invalidationHandler called
body: <p>I'm having an issue when I try to Launch Instagram from my app. Everything works and I'm able to launch IG and even see the photo I sent etc.  </p>
  
  <p>The problem is that the <code>UIDocumentInteractionController</code> is crashing my app.  And YES I have done my research.</p>
  
  <p>I've seen the posts <a href="https://stackoverflow.com/questions/26183334/uiactivityviewcontroller-launchservices-invalidationhandler-called">LIKE THIS</a> that indicate that this is an Apple bug as as long as you can fix the crash, you should be able fine and ignore the Launch Services message.  </p>
  
  <p>The problem is I am still having the crash and trying to figure out how to resolve it.</p>
  
  <p>I found a post that talks about adding an IF-STATEMENT after presenting the <code>ViewController</code> <a href="https://stackoverflow.com/questions/25759380/launchservices-invalidationhandler-called-ios-8-share-sheet">HERE</a>, this post was written in Objective-C, and the example was not for a <code>UIDocumentInteractionController</code>.  </p>
  
  <p>I tried to take a stab at it in Swift, but it is still not working out for me.  Would appreciate if someone can help out.</p>
  
  <pre><code>dic = UIDocumentInteractionController(URL: imageURL!)
  dic.delegate = self
  
  var annotationDictionary: [String: String] = ["InstagramCaption": "Test"]
  dic.annotation = annotationDictionary
  dic.UTI = "com.instagram.exclusivegram"
  
  dic.presentOpenInMenuFromRect(CGRectMake(1, 1, 1, 1), inView: self.view, animated: true)
  
  if dic.respondsToSelector("popoverPresentationController") {
  
      Scripts.log("InstagramVC Did Respond to popoverPresentationController")     
      var popoverController: UIPopoverPresentationController = self.popoverPresentationController!        
      popoverPresentationController?.sourceView = self.view       
  }
  </code></pre>