I have tried this:
In .h file :
@interface TouchLabelViewController : UIViewController<UITextFieldDelegate>
@property (strong, nonatomic) IBOutlet UITextField *aTextField;
-(IBAction)hideKeyboard:(id)sender;
In .m File :
-(IBAction)hideKeyboard:(id)sender{
[(UITextField*)sender resignFirstResponder];
}
And also tried this.
In .h file :
- (void)viewDidLoad
{
[super viewDidLoad];
aTextField.delegate = self;
}
@property (strong, nonatomic) IBOutlet UITextField *aTextField;
-(BOOL) textFieldShouldReturn:(UITextField *)textField;
In .m file:
-(BOOL) textFieldShouldReturn:(UITextField *)textField{
[aTextField resignFirstResponder];
return YES;
}
But still whenever I touch return key it does not hide keyboard.
You can take Advantage of these(delegate) methods when you set the delegate to the Textfield.
YOu should Check your delegate whether you have set the delegate to the Textfield
set this In your
.hClassNow Where you created the TextField set delegate like below
And further do same as you were doing
EDIT: In case if you were presenting the Current as
UIModalPresentationFormSheetPresentation modes may keep the keyboard visible when not required.
Default implementation affects UIModalPresentationFormSheet visibility.that’s why need to overriding it for hiding keyboard