I have a function
@IBAction func fblogin(sender: AnyObject) {
println (sender)
}
The action of two button is this function. If I print sender nil gets printer. How do I check which button called it. Do I need to create outlet for buttons or how do I create ids for buttons?
You could use sender
's tag
value
Just connect both buttons to your action, and check with:
if(sender.tag == 1) {
... button 1
} else if( sender.tag == 2) {
.. button 2
}
And use sender from type UIButton (you can select it directly in Xcode too)
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.