ios - UIDocumentInteractionController PresentOpenInMenuFromRect

标签 ios xcode swift uidocumentinteraction

我有从 UIAlertController 中调用的代码:

func createSomeFile() {

    var output = (some NSData to output to file)


    let fileName = NSTemporaryDirectory().stringByAppendingPathComponent("filename.ext")
    let url: NSURL! = NSURL(fileURLWithPath: fileName)

    var dataToWrite = output.dataUsingEncoding(NSUTF8StringEncoding)
    dataToWrite?.writeToFile(url.absoluteString!, atomically: true)

    documentController = UIDocumentInteractionController(URL: url)
    documentController.UTI = "com.someUTI"
    documentController.delegate = self

    documentController.presentOpenInMenuFromRect(CGRectZero, inView: self, animated: true)
}

最后一行在 Xcode 中引发错误:“无法使用类型的参数列表调用 'presentOpenInMenuFromRect'...”

documentController 被声明为类变量 var documentController = UIDocumentInteractionController()

请帮我解决这个问题。

最佳答案

您无法分配 self一个参数应该是 UIView (除非 selfUIView 的子类,但显然不是)

所以试试这个:

documentController.presentOpenInMenuFromRect(CGRectZero, inView: self.view, animated: true)

关于ios - UIDocumentInteractionController PresentOpenInMenuFromRect,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/31201355/

相关文章:

iphone - 键盘出现时如何向上 ScrollView ?

ios - Swift:如何通过按导航栏按钮访问选项卡栏项目

swift - UITextView 中的多个超链接 : Underlined and Bold, 粗体不起作用

iOS 应用程序内存限制

ios - 变量闭包初始化问题

ios - 如何管理 iOS apns token 更改

ios - XCode 线程中的断点

IOS应用程序在正常工作几个月后无法安装

c++ - XCode 主题到 Notepad++?

swift - 无法在新的 Xcode 10.2 (iOS 12.2) 中构建 Alamofire 框架