Project3-FileManager, UIActivity

2016-09-26  本文已影响0人  终极解码者

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)
}
上一篇下一篇

猜你喜欢

热点阅读