objective c - Programmatically change focus after input text in UITextfield -


i have simple view has 2 textviews button. controls positioned vertically. can navigate 1 control using remote. however, i'm trying following scenario working:

  1. the user launches app (focus on first textfield)
  2. the user enters textfield , uses fullscreen keyboard, hits "next" button
  3. the app shows second textfield (fullscreen keyboard), types in text , hits "done" button
  4. the app leaves fullscreen keyboard , focuses button

while step 1-3 working out of box, changing focus programatically (4) doesn't work. here's code:

- (bool)textfieldshouldreturn:(uitextfield *)textfield {     if(textfield == self.textfieldb) {         self.activeview = self.textfieldb;         [self setneedsfocusupdate];         [self updatefocusifneeded];         return yes;     }      return no; } 

and in - (uiview *)preferredfocusedview i'm returning whatever stored in self.activeview (yes, return button instance). methods called expected, focus doesn't change. doing wrong here?

thanks in advance!

according this developer forums thread behaviour intentional:

when dismissing presented view controller, fullscreen keyboard, uikit automatically return focus when view controller first presented, if view still focusable. focus automatically returns user expect be. there no mechanism overriding behavior.

in similar case switched focus delay after returning keyboard screen. it’s ugly hack, wish uikit wasn’t opinionated this.


Comments

Popular posts from this blog

sql - VB.NET Operand type clash: date is incompatible with int error -

SVG stroke-linecap doesn't work for circles in Firefox? -

python - TypeError: Scalar value for argument 'color' is not numeric in openCV -