I'm creating a view which provides some fields for the user to fill in - address, phone number etc.
I've seen apps that have populated fields with grey text like 'Fill in your name here' on the Name field, and when the user taps on it the text is gone, a keyboard appears and the view is zoomed in to the textfield(or whatever it is). Also, after filling up that field tapping the 'Next' button on the keyboard brings the user to the next field. I'm trying to do the same but I have no idea where to get sources on this. Pardon my poor googling skills ;p
Tried UITextView and UITextField but there isn't anything related to this on the Interface Builder. Figured it lies with the codes?
It'd be great if I can get some explanation or some links on how this works (: Thanks!
EDIT: okay I played around with the In开发者_Go百科terface Builder a lil more and realized I could set placeholder as the grey text.
It is in fact a UITextField
.
- You can get the greyed out text by setting its
placeholder
property. - I am not sure what you mean by zooming but usually they do use a scroll view or adjust the frame so that it isn't blocked by the keyboard.
- The
Next
button is made available using aUIToolbar
instance as the text field'sinputAccessoryView
. However the implementation is one's own and is not framework provided. You can look atthis example
to get started.
精彩评论