我有从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/

10-11 16:14