Answer the question
In order to leave comments, you need to log in
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
}
}
}
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()
}
keyView.addTarget(delegate, action: "updateButtons:", forControlEvents: [.TouchDown, .TouchDragInside, .TouchDragEnter])
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question