gpt4 book ai didi

ios - Xcode 6.3 beta 2 中函数的错误消息

转载 作者:行者123 更新时间:2023-11-29 02:16:06 26 4
gpt4 key购买 nike

我刚刚打开了最新的 Xcode beta (8.3 beta 2),并且正在将我的代码转换为 Swift 1.2。我遇到了特定代码行的问题,我无法找出解决方案。

基本上我收到错误:Objective-C 方法“textFieldShouldReturn:”由方法“textFieldShouldReturn”提供,与协议(protocol)“UITextFieldDelegate”中的可选要求方法“textFieldShouldReturn”冲突

就是这段代码:

@IBAction func textFieldShouldReturn(textField: UITextField!)
{
budgetNameText.resignFirstResponder()
}

有人知道解决办法吗?

最佳答案

正如您在错误消息中看到的,已经有一个与您的方法类似的方法。所以你的问题是,在 UITextFieldDelegate 中,还有一个名为 textFieldShouldReturn 的方法。 。因此,您需要将您的 IBAction 方法重命名为其他名称。

这是委托(delegate)提供的方法:

func textFieldShouldReturn(textField: UITextField) -> Bool {
return true
}

关于ios - Xcode 6.3 beta 2 中函数的错误消息,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/28731872/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com