swift - ios: while editing in textview, keyboard return key not working -
func textview(_ textview: uitextview, shouldchangetextin range: nsrange, replacementtext text: string) -> bool { if text == "\n" { tempdescription = txteditdescription.text txteditdescription.resignfirstresponder() return false } return true }
i'm new in ios developement string variable -> "tempdescription" want store edited text in string variable on keyboard return key.
it textview -> "txteditdescription" through above method simulator keyboard not hide. have ? thanks
by default, return key not hooked functionality.
to this, implement uitextfielddelegate on class by:
class viewcontroller: uiviewcontroller, uitextfielddelegate { }
then in viewdidload assign delegate of textfield iboutlet self by:
textfield.delegate = self
then implement following method uitextfielddelegate: (this function fires when return key hit, override functionality want.)
func textfieldshouldreturn(_ textfield: uitextfield) -> bool { tempdescription = txteditdescription.text textfield.resignfirstresponder() return true }
Comments
Post a Comment