iOS DevelopmentSwift

swift -- 系统自带分享功能

2017-02-27  本文已影响119人  71150ce14a00
分享

UIActivityViewController类中只有三个方法

  1. init(activityItems: [AnyObject], applicationActivities: [AnyObject]?) //初始化方法
  1. var completionHandler: UIActivityViewControllerCompletionHandler? //结束后执行的block
  2. var excludedActivityTypes: [AnyObject]?//排除的Activity
    let textToShare = "百度"
    let imageToShare = UIImage.init(named: "img_01")
    let urlToShare = NSURL.init(string: "http://www.baidu.com")
    let items = [textToShare,imageToShare ?? "WeShare",urlToShare ?? "WeShare"] as [Any]
    let activityVC = UIActivityViewController(
        activityItems: items,
        applicationActivities: nil)
   activityVC.completionWithItemsHandler =  { activity, success, items, error in
     print(activity)
        print(success)
        print(items)
        print(error)
        
        
    }
    self.present(activityVC, animated: true, completion: { () -> Void in
        
    })
上一篇下一篇

猜你喜欢

热点阅读