Quick Tip - Keyboard and becomeFirstResponder

I found myself in a situation where tapping on a UITextField popped up the keyboard (as you would expect), but I wanted to be able to dimiss the keyboard when a particular button in the interface was tapped. I tried to send the button a becomeFirstResponder: message but that didn't work. Then I found that you have to set the canBecomeFirstResponder property of the button to YES before you can call becomeFirstResponder:.

All UIViews inherit from UIResponder, but some views, such as buttons have the canBecomeFirstResponder property set to NO by default.