1).
[self.view endEditing:YES];
2).
you set the delegate method.
SOMEFIELD.text =delegate;
And .h file
@interface yourViewController : UIViewController<UITextFieldDelegate>
and in .m file you add the delegate method of the textfield
- (BOOL)textFieldShouldReturn:(UITextField *)textField {
[textField resignFirstResponder];
return YES;
}