在我的应用程序中,我按下一个按钮,它会弹出一个模态演示表单(适用于iPad)。在这个模态视图中,我有一个滚动视图和一个文本框。滚动视图位于主视图中。
view controller
view
scrollview
text field
我尝试的所有方法都没有使键盘消失,也不知道原因。唯一发生的事情就是文本字段中闪烁的光标消失了。我的类是滚动视图和文本字段的代理。以下是我尝试过的方法:
- (void)scrollViewDidScroll:(UIScrollView *)scrollView{
[self.titleTextField resignFirstResponder];
[self.titleTextField endEditing:YES];
[self.view endEditing:YES];
[self.view resignFirstResponder];
[self.scrollView endEditing:YES];
[self.scrollView resignFirstResponder];
}
该方法确实被调用,但键盘不会自动消失。有人可以帮我或者至少告诉我为什么吗?
以下是我展示该modalpresentation视图的方式:
(它来自一个tableviewcontroller)
didSelectRowAtIndexPath
EditVideo *targetController = [self.storyboard instantiateViewControllerWithIdentifier:@"editVideo"];
targetController.delegate = self;
UINavigationController *navigationController = [[UINavigationController alloc] initWithRootViewController:targetController];
navigationController.modalPresentationStyle = UIModalPresentationFormSheet;
[self presentViewController:navigationController animated:YES completion:nil];
[self.tableView deselectRowAtIndexPath:indexPath animated:YES];