views:

179

answers:

2

Hi all -

The latest version of Apple's UICatalog example application includes zero code in the TextFieldController for handling keyboard show/hide events, and yet the table view still slides up and down beautifully with the keyboard.

Does anyone know what the new trick is? Are there settings in the XIB that allowed them to forgo registering for the notifications or using TextField delegate methods?

The TextViewController still uses keyboard notifications to deal with view sliding, so I'm really confused as to why this isn't included for TextFields anymore.

Thoughts?

A: 

You can close the keyboard, if it's open by calling:

[sender resignFirstResponder];

Not sure about opening the keyboard however.

Jamie Chapman
Jamie, you're right. I should have been more specific. There's no code to slide the scroll view associated with a keyboard showing or hiding...it just seems to scroll perfectly to the selected text field. Thanks though.
Wireless Designs
A: 

The trick is hidden within calling becomeFirstResponder on a UITextField that is in a scrollable view. Apparently, whenever calling [textField becomeFirstResponder], iOS automatically scrolls the parent view until said textField is visible.

This behavior can actually be undesirable in some cases, as it will not usually scroll to the same location that the UIScrollView method scrollRectToVisible:animated: would if you were to try to do things that way.

Thanks for your thoughts everyone!

Wireless Designs