Skip to content

Instantly share code, notes, and snippets.

@MTattin
Created March 6, 2016 12:46
Show Gist options
  • Save MTattin/1d8640dbc11e68841a99 to your computer and use it in GitHub Desktop.
Save MTattin/1d8640dbc11e68841a99 to your computer and use it in GitHub Desktop.
swift2.0でのシェア方法の自分用メモ ref: http://qiita.com/MTattin/items/a911ef686144f5a84b0a
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)
}
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