在此方面的帮助将不胜感激。
我想从 iOS 应用程序中发送短信。
在 Xcode 中,我做了以下事情:
在 Link Binary With Library 中添加了一个引用:
MessageUI.framework
在 ViewController.swift 中我添加了导入:
import MessageUI
但是,当我尝试添加委托(delegate)时......
class ViewController: UIViewController, MFMessageComposeViewControllerDelegate {
override func viewDidLoad() {
super.viewDidLoad()
// Do any additional setup after loading the view, typically from a nib.
}
override func didReceiveMemoryWarning() {
super.didReceiveMemoryWarning()
// Dispose of any resources that can be recreated.
}
}
我收到这个错误:
类型“ViewController”不符合协议(protocol)“MFMessageComposeViewControllerDelegate”
更新
按照安东尼奥的建议解决了。我添加了这个:
func messageComposeViewController(controller: MFMessageComposeViewController!, didFinishWithResult result: MessageComposeResult) {
}
最佳答案
这意味着你还没有实现协议(protocol)中定义的方法。看documentation了解您必须实现的内容。
在这种情况下,它只是一个方法:
func messageComposeViewController(_ controller: MFMessageComposeViewController!, didFinishWithResult result: MessageComposeResult)
关于Xcode - 无法采用协议(protocol),我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/26983222/