Dismiss Keyboard presented in modal View Controller (Form sheet)

岁酱吖の 提交于 2019-12-08 02:43:46

问题


I have a modal View Controller, presented as Form Sheet on the iPad. When I send [textField resignFirstResponder], the Keyboard remains on the screen.

In the View Controller:

- (BOOL)textFieldShouldEndEditing:(UITextField *)textField
{
    return YES;
}

- (BOOL)textFieldShouldReturn:(UITextField *)textField
{
    [textField resignFirstResponder];

    return YES;
}

In the Navigation Controller:

- (BOOL)disablesAutomaticKeyboardDismissal
{
    return NO;
}

All this worked using iOS 6, but not with iOS 7.


回答1:


Adding the following method to the actual ViewController (rather than the NavigationController) worked for me in iOS 7.

- (BOOL)disablesAutomaticKeyboardDismissal
{
    return NO;
}

I'm calling a method that is hooked to the Text Field's Sent Event Editing Did End.

- (IBAction)KeyboardDoneKeyPressed:(id)sender
{
   [sender resignFirstResponder];
}

Prior to adding the method disablesAutomaticKeyboardDismissal the keyboard would not dismiss when pressing Done.



来源:https://stackoverflow.com/questions/19237932/dismiss-keyboard-presented-in-modal-view-controller-form-sheet

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!