swift - 'resignFirstResponder()' returns true and the text field loses focus but the keyboard does not dismiss -


i have storyboard scene has 2 uitextfield.the first 1 left untouched, fresh out of object library. second 1 has delegate outlet connected viewcontroller's code.

app's interface

the second text field's connection in ib

(sorry have post images way, because stackoverflow won't let me.)

the code simple. of it.

class viewcontroller: uiviewcontroller, uitextfielddelegate {         func textfielddidbeginediting(textfield: uitextfield) {         textfield.resignfirstresponder()     } } 

the thing dismiss keyboard when it's come up.

the first 1 shows keyboard normally. second 1 doesn't show keyboard because it's dismissed.

it works on own, until click first text field bring keyboard, keyboard on screen, click second text field. happens next, second text field loses focus, keyboard remains on screen.

using print(:), i've verified that, when call resignfirstresponder on second text field, first responder, , return value of call true, , after call no longer first responder.

but keyboard still there...

i tried adding print(:) in delegate's textfieldshouldreturn(:) method, , clicking return key after text field resigned. there nothing printed in debug console.

i tried disablesautomatickeyboarddismissal(), returning neither false nor true produces difference.

edit

what want simple: want first text field whatever it's default do, , second 1 dismiss keyboard it's tapped (from user's perspective, meaning not showing it).

i know textfieldshouldbeginediting(:), can't use various reasons, have dismiss keyboard after it's been activated.

edit again

i tried view.endediting(true) well. in fact, tried .endediting(true) on every view in scene. doesn't work.

try smth that:

func textfieldshouldbeginediting(textfield: uitextfield) -> bool {     view.endediting(true)     return true }  func textfielddidbeginediting(textfield: uitextfield) {     textfield.resignfirstresponder()     //make here whatever  } 

Comments

Popular posts from this blog

php - Invalid Cofiguration - yii\base\InvalidConfigException - Yii2 -

How to show in django cms breadcrumbs full path? -

ruby on rails - npm error: tunneling socket could not be established, cause=connect ETIMEDOUT -