共享按钮不显示应用程序(Swift/Xcode)



我正在尝试让我的应用程序共享PDF。但是当按下共享按钮并显示共享时,没有什么可供选择的。只有"[...]更多",没有提供任何选择。谁能帮我?我的代码是:

import UIKit
import WebKit

class PDF1: UIViewController {

    @IBOutlet var webView: WKWebView!
    override func viewDidLoad() {
        super.viewDidLoad()
        let path = Bundle.main.path(forResource: "Brewolution A Bunnys Tale - Påske 2012", ofType: ".pdf")
        let url = URL(fileURLWithPath: path!)
        let request = URLRequest(url: url)
        webView.load(request)
        // Do any additional setup after loading the view.
    }
    override func didReceiveMemoryWarning() {
        super.didReceiveMemoryWarning()
        // Dispose of any resources that can be recreated.
    }
    @IBAction func sharePressed(_ sender: Any) {
        let activityController = UIActivityViewController(activityItems: [self.webView], applicationActivities: nil)
        present(activityController, animated: true, completion: nil)
    }

} 

您不能像当前那样共享像self.webview这样的UI组件,只能共享文本,图像,,,,等,其中有来自其他应用程序的扩展支持此类项目类型,并且将立即显示

    let shareText = "PDF URL add"
    if let image = UIImage(named: "share.png") {
        let vc = UIActivityViewController(activityItems: [shareText, image], applicationActivities: [])
        present(vc, animated: true, completion: nil)
    }

最新更新