从WebView Xcode共享PDF文件

时间:2015-04-27 14:15:21

标签: xcode swift uiactivityviewcontroller

您好我已尝试使用此代码但未使用

var pdfLoc = NSData(contentsOfURL: NSURL(string: "http://www.triestetrasporti.it/download.php?f=c113b7c217cdffd07ee371678a8f8699&target=0.pdf")!)

var oggetti  = [pdfLoc]
        let activityViewController : UIActivityViewController = UIActivityViewController(activityItems: oggetti, applicationActivities: nil)

错误:无法找到类型'UIActivityViewController'的初始值设定项,它接受类型'(activityItems:[NSData?],applicationActivities:nil)'的参数列表

1 个答案:

答案 0 :(得分:5)

UIActivityViewController期望初始化一个NSData数组,但您的oggetti变量是 Optional NSData的数组。

我猜你应该解开它:

var oggetti = [pdfLoc!]

See Apple documentation about this here.