在swift中打开分享功能原来是如此的简单。
1、首先需要
import Social
2、在分享按钮事件下面
var controller:SLComposeViewController = SLComposeViewController(forServiceType: SLServiceTypeSinaWeibo)
controller.setInitialText("一起来swift吧!")
controller.addImage(UIImage(named: "app720_12801"))
self.presentViewController(controller, animated: true, completion: nil)
这样就打开了分享到新浪微博窗口
swift 中自带的有4个值,分别为
SLServiceTypeTwitter
SLServiceTypeFacebook
SLServiceTypeSinaWeibo
SLServiceTypeTencentWeibo
一看就明白了,但是要分享到微信应该还要看微信的api才行。