我试图从模态视图控制器中隐藏 iPad 键盘,但它不起作用.我已经尝试过 resignFirstResponder ,但是如果我们在模态视图控制器中,这不会有任何影响.我在具有相同 UIViewController 的非模态 UINavigationController 中尝试了 resignFirstResponder 并且键盘隐藏正确.
I'm trying to hide the iPad keyboard from a modal view controller but it doesn't work. I have tried resignFirstResponder but that doesn't have any affect if we are in a modal view controller. I tried resignFirstResponder in a non-modal UINavigationController with the very same UIViewController and the keyboard hides correctly.
有人知道怎么解决这个问题吗?
Does anyone know how solve this problem?
谢谢.
[更新] 我的代码似乎有问题,因为 resignFirstResponder 确实有效(我做了一个简单的测试用例而不是使用我的代码).但我还是不知道问题出在哪里.
[Update] it looks like there's something wrong with my code because the resignFirstResponder does work (I made a simple test case instead of using my code). But I still don't know what the problem is.
因为我用的是 UIModalPresentationFormSheet.所有其他的都按预期工作....浪费了几个小时.
It was because I was using UIModalPresentationFormSheet. All of the other ones work as expected.... Wasted several hours on that.
这篇关于如何从 MODAL 视图控制器中隐藏 iPad 键盘?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持跟版网!