美文网首页iOS DevelopmentSwift
swift -- 系统自带分享功能

swift -- 系统自带分享功能

作者: 71150ce14a00 | 来源:发表于2017-02-27 11:45 被阅读119次
    分享

    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
            
        })

    相关文章

      网友评论

      本文标题:swift -- 系统自带分享功能

      本文链接:https://www.haomeiwen.com/subject/qllzwttx.html