How to dismiss keyboard from childViewController which is in containerView in parentViewController?

624 Views Asked by At

I need to dismiss keyboard which show itself when I click UITextField from childView. I need to do this in method (scrollViewWillBeginEditing) which is in parentViewController. How can I do it?

EDIT:

I have method in childViewController:

- (void)dismissKeyboard {
    [self.textField resignFirstResponder];
    NSLog(@"%@", self.textField.text);
}

and .h of childViewController:

@protocol VVInformationTableViewControllerDelegate<NSObject, UIScrollViewDelegate>
-(void)dismissKeyboard;
@end

@interface VVInformationTableViewController : UITableViewController <UITextFieldDelegate, UITableViewDelegate, UIScrollViewDelegate, VVInformationTableViewControllerDelegate>

@property (weak, nonatomic) id<VVInformationTableViewControllerDelegate> delegate;

and I try to call it in:

-(void)scrollViewWillBeginDragging:(UIScrollView *)scrollView{
        [self.infoTableController dismissKeyboard];    
}

When it is call then NSLog print (null) and keyboard didn't dismiss, but when I call dismissKeyboard from childViewController then it print true value and keyboard dismiss.

Any help?

1

There are 1 best solutions below

2
On

You can use the following code

 [self.childView endEditing:Yes];