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

Popular posts from this blog

javascript - Clear button on addentry page doesn't work -

c# - Selenium Authentication Popup preventing driver close or quit -

tensorflow when input_data MNIST_data , zlib.error: Error -3 while decompressing: invalid block type -