M
M
mechanicnikodimich2016-03-19 11:05:32
Swift
mechanicnikodimich, 2016-03-19 11:05:32

Why is the TextLabel on the button not updating?

Good day.
I'm trying to "reinvent the wheel" and make an analogue of the predicative set in the custom keyboard. The process has reached the point that I placed three buttons in the TopBanner of the keyboard, by clicking on which the text displayed on the buttons is printed.
But at the same time, when you click on the keyboard button, you need to update the text on the button.
Actually, here is the code:

protocol updateBattonsTitels:class {
    func updateButtons(sender: KeyboardKey)
}

class Catboard: KeyboardViewController {
    var delegate: updateBattonsTitels?
    
    override init(nibName nibNameOrNil: String?, bundle nibBundleOrNil: NSBundle?) {
        NSUserDefaults.standardUserDefaults().registerDefaults([kCatTypeEnabled: true])
        super.init(nibName: nibNameOrNil, bundle: nibBundleOrNil)
    }

    required init?(coder: NSCoder) {
        fatalError("init(coder:) has not been implemented")
        
    }
    

    
    override func keyPressed(key: Key) {
         let textDocumentProxy = self.textDocumentProxy
        if let keyView = self.layout?.viewForKey(key) {
            switch key.type {
            case Key.KeyType.Character:
                keyView.addTarget(delegate, action: "updateButtons:", forControlEvents:  [.TouchDown, .TouchDragInside, .TouchDragEnter])
            
            default:
                break
            }
        }
}

And the second part with buttons:
extension CatboardBanner: updateBattonsTitels {
    func updateButtons ( sender: KeyboardKey)
    {
        lBatton.setTitle("75%", forState: UIControlState.Normal)
        cBatton.setTitle("90%", forState: UIControlState.Normal)
        rBatton.setTitle("54%", forState: UIControlState.Normal)
        
    
    }
    
}



class CatboardBanner: ExtraView {
    var delegate: insertBattonText?
    var catSwitch: UISwitch = UISwitch()
    var lBatton: UIButton = UIButton()
    var cBatton: UIButton = UIButton()
    var rBatton: UIButton = UIButton()
}

The code in the abbreviated content, if necessary, I can lay out the extended version, so to speak, of everything.
The problem is that when you click on the button
keyView.addTarget(delegate, action: "updateButtons:", forControlEvents:  [.TouchDown, .TouchDragInside, .TouchDragEnter])

It seems to work, but nothing is updated on the buttons.
How to be?

Answer the question

In order to leave comments, you need to log in

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question