Hello!
I need to get the title of a button, but i see only "Button" when i execute the function.
For example: the title of the button is "Test"..and when i press on it , i need to see in my debugging "Test". In the screen of my Ipad i see the button with "Test" title.
At the moment, i see "Button". What i'm wrong?
I've wrote it in swift and i paste here the code.
I need to get the title of a button, but i see only "Button" when i execute the function.
For example: the title of the button is "Test"..and when i press on it , i need to see in my debugging "Test". In the screen of my Ipad i see the button with "Test" title.
At the moment, i see "Button". What i'm wrong?
I've wrote it in swift and i paste here the code.
Code:
var name = "Test"
let button = UIButton()
button.setTitle("\(name)", forState: UIControlState.Normal)
button.setTitleColor(UIColor.blueColor(), forState: .Normal)
button.frame = CGRectMake(15, CGFloat(altezza), 300, 700)
button.addTarget(self, action: "open:", forControlEvents: .TouchUpInside)
self.view.addSubview(button)
func open(sender:UIButton)
{
if let text = bottone.currentTitle {
println(" \(text)")
}
else{ println ("ok") }
}