Change Button label with typed value

Asked

Viewed 389 times

0

I have an application that when I touch the button should open the keyboard and the value that the user needs to be inserted in the button label, I do not know how to do this, someone can help, in case it would be in Swift 3

1 answer

0

@IBAction func userInput(sender: UITextField) {
MeuBotao.setTitle(sender.text,for: .normal)
}
  • In this case where the Meubotao has to be declared?

  • Dude, you’re new to developing for IOS ? You can use your own design tool to create the button in your application and name it whatever you want. Or if you want via code it would look like this: Let Meubotao = Uibutton(frame: Cgrect(x: 100, y: 100, width: 100, height: 50)). It would be nice to read some tutorials, I think it will help you a lot and will also prevent the staff from a downvote on you here at stackoverflow.

  • I’m not a beginner, I just got confused because the userinput you put would be the name of the button if you haven’t mistaken. even with the design tool it will pick up and insert for example: @Ibaction func userinput, the userinput would be the name of the button, so I learned, if I’m wrong sorry, I don’t really have much experience in the development of Ios

  • Sorry, I could only answer now. You can relax, no problem. There are 2 types of label text and name (This is the name of the button like your id "My button"). In the design part goes in the properties of the button you see all the options they have. Good luck.

  • The text property does not exist in Uibutton. The correct way is: meuBotao.setTitle(sender.text, for: .normal).

  • You are right, in Swift changed , different from the pure objectivC. Thank you.

  • Guys, thank you so much for the help, I don’t know if I can express myself right, but so, on Android I made an app, I have a button, when the user selects it, it opens another 'screen' we can say that a modal, then enables a space for it to enter a value, when it confirms this modal is closed and updates the text inside the button, similar serious? or would have to use longPress?

Show 2 more comments

Browser other questions tagged

You are not signed in. Login or sign up in order to post.