iphone - becomeFirstResponder: automatically scroll to the UIControl that becomes first responder -
i have grouped uitableviewcontroller
1 section , many rows. each cell
consists of 2 elements: uilabel
description , uitextfield
input. form, say.
on bottom button "next" go next view. before that, validate uitextfield
's: if user hasn't filled field, field should focus, user sees needs enter something. tried this:
[inputfield becomefirstresponder];
remember, button pressed on bottom of view , imagine uitextfield
on top. in situation, field doesn't focus because far away. when scroll , field gets visible, field becomes first responder , gets cursor :-) conclusion: becomefirstresponder
worked, not wanted to. don't want scroll finger, field should focus , visible automatically.
is there way "jump" directly field? use alternative becomefirstresponder
? scroll field automatically?
thanks help!
if know index of cell uitextfield want edit, use
nsindexpath* indexpath = [[nsindexpath indexpathwithindex:your_section_index] indexpathbyaddingindex:your_cell_index]; [tableview scrolltorowatindexpath:indexpath atscrollposition:uitableviewscrollpositionbottom animated:yes]
before call becomefirstresponder
.
if cell off screen, becomefirstresponder may fail versions of ios. in addition, versions perform additional scrolling on tableview in situations (e.g. if apple's code determines responder still off screen without more scrolling). around these issues, may need call become first responder after scroll animation complete.
Comments
Post a Comment