UIActivityViewController类中只有三个方法
- init(activityItems: [AnyObject], applicationActivities: [AnyObject]?) //初始化方法
- var completionHandler: UIActivityViewControllerCompletionHandler? //结束后执行的block
- 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
})
网友评论