ios学习:swift中实现分享到微博、facebook,twitter等

在swift中打开分享功能原来是如此的简单。

1、首先须要

import Social

2、在分享button事件以下

  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才行。