objective c - Obj C - resign first responder on touch UIView -


i'm trying keyboard disappear when screen touched, question answered on stackoverflow. able keyboard disappear when enter key pressed thread here. i'm not having luck on background touch resigning first responder. method being entered, have nslog in method saying, "in backgroundtouched" keyboard still there.

i've tried making uiview uicontrol class use touch event. journalcomment uitextview.

-(ibaction)backgroundtouched:(id)sender     {         [journalcomment resignfirstresponder];         nslog(@ "in backgroundtouched");  } 

i've tried having invisible button under calles backgroundtouched method. think maybe i'm missing in interface builder, i'm not sure what.

thank help!

this works done button:

-(bool)textview:(uitextview *)textview shouldchangetextinrange:(nsrange)range   replacementtext:(nsstring *)text {     // new character added passed in "text" parameter     if ([text isequaltostring:@"\n"]) {         // sure test equality using "isequaltostring" message         [textview resignfirstresponder];          // return false final '\n' character doesn't added         return false;     }     // other character return true text gets added view     return true; } 

try this. had problem eariler, found right solution.

  -(void)touchesbegan:(nsset *)touches withevent:(uievent *)event{          [yourtextfield resignfirstresponder];          // can have multiple textfields here       } 

this should resolve problem keyboard not dissapearing when pushing background.


Comments

Popular posts from this blog

php - What is the difference between $_SERVER['PATH_INFO'] and $_SERVER['ORIG_PATH_INFO']? -

fortran - Function return type mismatch -

queue - mq_receive: message too long -