Created
February 15, 2016 19:16
-
-
Save danielgalasko/9755e4b0d334081b4529 to your computer and use it in GitHub Desktop.
This file contains 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
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