social.Framework提供了常见的社交媒体分享API。这样我们不需要导入SDK。
提供了
SLServiceTypeFacebook
SLServiceTypeSinaWeibo
SLServiceTypeTencentWeibo
SLServiceTypeTwitter
首先我们要导入Social
import Social
@IBAction func saveAction(sender: AnyObject) {
var controller:SLComposeViewController = SLComposeViewController(forServiceType: SLServiceTypeSinaWeibo)
controller.setInitialText("分享内容")
controller.addImage(nil)
self.presentViewController(controller, animated: true, completion: nil)
}
记住微博分享需要在真机下测试。否则报错