Skip to content

Instantly share code, notes, and snippets.

@danielgalasko
Created February 15, 2016 19:16
Show Gist options
  • Save danielgalasko/9755e4b0d334081b4529 to your computer and use it in GitHub Desktop.
Save danielgalasko/9755e4b0d334081b4529 to your computer and use it in GitHub Desktop.
class TweetViewController: UIViewController {
var initiatingPreviewActionController: UIViewController?
override func previewActionItems() -> [UIPreviewActionItem] {
guard let initiatingPreviewActionController = initiatingPreviewActionController else {
assert(false, "Expected initiatingPreviewActionController to be set")
return []
}
return [UIPreviewAction(title: "Share", style: .Default,
handler: {[unowned self] (_, _) -> Void in
let shareSheet = self.createShareSheet()
shareSheet.popoverPresentationController?.sourceView = self.view
initiatingPreviewActionController.presentViewController(shareSheet, animated: true, completion: nil)
}),
UIPreviewAction(title: "Favorite", style: .Default,
handler: {[unowned self] (_, _) -> Void in
self.favoriteTweet()
})]
}
func createShareSheet() -> UIViewController {
return UIActivityViewController(activityItems: ["www.twitter.com/tweeturl"], applicationActivities: nil)
}
func favoriteTweet() {
//favorites a tweet
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment