0

I created a custom input view with a couple of UIButtons inside it. All these buttons invoke one single IBAction.

The IBAction is not called although I'am 100% sure I set them properly in IB. To prove that this isn't causing the problem I added a target to one of the buttons programmatically, but the action still won't get invoked.

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)
    }

}

enter image description here

I didn't implement the delegate properly yet, but that not the the point. The print("buttonTapped") won't even show up. The method just doesn't get called, I tested this using breakpoints.

Does anyone know what is causing this problem

Peter Combee
  • 595
  • 4
  • 10

0 Answers0