Ios 自定义输入视图中的UIButton不';不要调用任何方法

Ios 自定义输入视图中的UIButton不';不要调用任何方法,ios,uibutton,uikit,uiinputviewcontroller,Ios,Uibutton,Uikit,Uiinputviewcontroller,我创建了一个自定义输入视图,其中有几个UIButton。所有这些按钮都调用一个iAction 虽然我100%确定我在IB中正确设置了iAction,但没有调用它。为了证明这不会导致问题,我以编程方式向其中一个按钮添加了一个目标,但该操作仍然不会被调用 import UIKit protocol CashDeskInputDelegate: class { func didReceiveInput(inputValue: String) func didReceiveDone

我创建了一个自定义输入视图,其中有几个UIButton。所有这些按钮都调用一个iAction

虽然我100%确定我在IB中正确设置了iAction,但没有调用它。为了证明这不会导致问题,我以编程方式向其中一个按钮添加了一个目标,但该操作仍然不会被调用

import UIKit


protocol CashDeskInputDelegate: class {

    func didReceiveInput(inputValue: String)
    func didReceiveDoneMessage()
}

class CashDeskInputViewController: UIInputViewController {

    // Delegate
    weak var delegate: CashDeskInputDelegate?

    // Actions
    @IBAction func buttonTapped(sender: UIButton) {

        print("buttonTapped")

        guard let valueOfSender = sender.titleLabel?.text else {
            dismissKeyboard()
            return
        }

        valueOfSender == "Done" ? delegate?.didReceiveDoneMessage() : delegate?.didReceiveInput(valueOfSender)
    }



    // Test outlet
    @IBOutlet weak var firstButton: UIButton!

    override func viewDidLoad() {
        // Add an action to the first button for testing purposes.
        firstButton.addTarget(self, action: "buttonTapped:", forControlEvents: .TouchUpInside)
    }

}

我还没有正确地实现委托,但这不是重点。印刷品(“带纽扣的”)甚至不会出现。该方法没有被调用,我使用断点测试了它


有人知道是什么导致了这个问题吗?

请尝试清理并生成您的项目一次。@PK20我尝试过,但没有成功。您是否正在将View.endEditing设置为true?在类中的任何位置否。为什么以及在哪里使用或不使用它?