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:
- the user launches app (focus on first textfield)
- the user enters textfield , uses fullscreen keyboard, hits "next" button
- the app shows second textfield (fullscreen keyboard), types in text , hits "done" button
- 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
Post a Comment