如何从MODAL视图控制器隐藏iPad键盘? [英] How to HIDE the iPad keyboard from a MODAL view controller?
问题描述
我正试图将iPad键盘隐藏在模态视图控制器中,但它不起作用。我已经尝试过resignFirstResponder但是如果我们在一个模态视图控制器中那没有任何影响。我在非模态UINavigationController中尝试了resignFirstResponder,它具有完全相同的UIViewController,并且键盘正确隐藏。
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键盘?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!