如何使用SLComposeViewController swift在Facebook,Twitter和instagram上共享内容 [英] how to share content on facebook, twitter and instagram using SLComposeViewController swift

查看:568
本文介绍了如何使用SLComposeViewController swift在Facebook,Twitter和instagram上共享内容的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想使用SLComposeViewController快速在社交媒体上共享内容和图像.我也已经在objC中做到了这一点,但是我是Swift开发的新手.请建议我这个库或任何库是否有任何公共类可以快速在社交媒体上共享内容.

解决方案

不需要库.您需要做的是:

1)只需导入Social框架.

2)要在Facebook

上发布的代码

let vc = SLComposeViewController(forServiceType: SLServiceTypeFacebook)
vc.setInitialText("Picture Text")
vc.addImage(detailImageView.image!)
vc.addURL(NSURL(string: "http://anyurl.com"))
presentViewController(vc, animated: true, completion: nil)

3)要在Twitter上发布的代码

let vc = SLComposeViewController(forServiceType: SLServiceTypeTwitter)
vc.setInitialText("Picture Text")
vc.addImage(detailImageView.image!)
vc.addURL(NSURL(string: "http://anyurl.com"))
presentViewController(vc, animated: true, completion: nil)

i want to share content and images on social media using SLComposeViewController in swift. i have also done it in objC but i am new in swift development.please suggest me if there is any common class for this or Any library to share content on social media in swift.

解决方案

There is no need of library. What you need to do is:

1) Just import the Social framework.

2) Code to post on Facebook

let vc = SLComposeViewController(forServiceType: SLServiceTypeFacebook)
vc.setInitialText("Picture Text")
vc.addImage(detailImageView.image!)
vc.addURL(NSURL(string: "http://anyurl.com"))
presentViewController(vc, animated: true, completion: nil)

3) Code to post on Twitter

let vc = SLComposeViewController(forServiceType: SLServiceTypeTwitter)
vc.setInitialText("Picture Text")
vc.addImage(detailImageView.image!)
vc.addURL(NSURL(string: "http://anyurl.com"))
presentViewController(vc, animated: true, completion: nil)

这篇关于如何使用SLComposeViewController swift在Facebook,Twitter和instagram上共享内容的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆