Project3-FileManager, UIActivityViewController, Social,

1.利用FileManager获取Bundle下面的文件名

let fm = FileManager.default
let path = Bundle.main.resourcePath!
let items = try! fm.contentsOfDirectory(atPath: path)

2.利用UIActivityViewController分享内容

let vc = UIActivityViewController(activityItems: [imageView.image!], applicationActivities: [])
vc.popoverPresentationController?.barButtonItem = navigationItem.rightBarButtonItem  //适配iPad
present(vc, animated: true)

3.利用Social包分享内容

if let vc = SLComposeViewController(forServiceType: SLServiceTypeSinaWeibo) {
    vc.setInitialText("Look at this great picture!")
    vc.add(imageView.image!)
    vc.add(URL(string: "http://www.photolib.noaa.gov/nssl"))
    present(vc, animated: true)
}

你可能感兴趣的:(Project3-FileManager, UIActivityViewController, Social,)