Sure, you'll need to use UITextFieldDelegate, specifically, textFieldShouldReturn:
. All you have to do is specify that your class will conform to this protocol in your interface, and specify that this class as the delegate on the textfield's delegate property and you're good to go. That is, after returning no from textFieldShouldReturn:
. Or of course, this can be done conditionally.
- (BOOL)textFieldShouldReturn:(UITextField *)textField
{
if (someCondition == YES) {
return NO;
}
return YES;
}