我有从 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
(除非 self
是 UIView
的子类,但显然不是)
所以试试这个:
documentController.presentOpenInMenuFromRect(CGRectZero, inView: self.view, animated: true)
关于ios - UIDocumentInteractionController PresentOpenInMenuFromRect,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/31201355/