ios - Changing label text to what user inputs into UITextField -
this basic question i'm not sure problem is. i'm trying make simple "hello world" program user inputs want textfield , whatever enter goes label. however, nothing seems happening , i'm unsure why since push function worked how expected to.
import uikit class viewcontroller: uiviewcontroller { @iboutlet var popup: uitextfield! @iboutlet weak var helloworld: uilabel! @ibaction func push(_ sender: uibutton) { popup.ishidden = false popup.text = "hello world" } @ibaction func send(_ sender: uitextfield) { helloworld.text = sender.text } }
based on code provided, func send
unknown me, whether or not firing. func send
might called, might not, either way, strange see _ sender: uitextfield
ibaction
.
what event firing related uitextfield
? trying update helloworld uilabel
user types in uitextfield
?
to update uilabel
whatever has been typed in uitextfield
, need uibutton
touch inside ibaction
. think can delete ibaction func send
completely, unless trying update uilabel
user types in uitextfield
. make sure remove ibaction
outlet
storyboard if correct point.
based on code provided push
func not set text in uilabel
. assuming push
uibutton
touch inside ibaction
. can set helloworld uilabel
text, in func push
, not need use sender of event, try , see helloworld uilabel
text populated:
@ibaction func push(_ sender: uibutton) { //popup.ishidden = false //why doing this? uitextfield popup should visible if typing text it, code superfluous value of popup.ishidden false helloworld.text = popup.text popup.text = "hello world" }
if trying have uilabel
display text type uitextfield
should clarify question. , if case need make uiviewcontroller
uitextfielddelegate
Comments
Post a Comment