Created
March 6, 2016 12:46
-
-
Save MTattin/1d8640dbc11e68841a99 to your computer and use it in GitHub Desktop.
swift2.0でのシェア方法の自分用メモ ref: http://qiita.com/MTattin/items/a911ef686144f5a84b0a
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
func share1() { | |
let shareText = "テキストテキスト\nテキストテキスト" | |
let shareWebsite = NSURL | |
let shareImage = UIImage | |
let activityItems = [ | |
shareText, | |
shareWebsite, | |
shareImage, | |
] | |
let vc = UIActivityViewController(activityItems: activityItems, applicationActivities: nil) | |
presentViewController(vc, animated: true, completion: nil) | |
} |
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
func share2() { | |
let shareText = "テキストテキスト\nテキストテキスト" | |
let shareWebsite = NSURL | |
let shareImage = UIImage | |
let scl: SLComposeViewController = SLComposeViewController(forServiceType: SLServiceTypeTwitter) | |
scl.setInitialText(shareText) | |
scl.addImage(shareImage) | |
scl.addURL(shareWebsite) | |
presentViewController(scl, animated: true, completion: {}) | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment