美文网首页
Project3-FileManager, UIActivity

Project3-FileManager, UIActivity

作者: 终极解码者 | 来源:发表于2016-09-26 11: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)
    }
    

    相关文章

      网友评论

          本文标题:Project3-FileManager, UIActivity

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