How to HIDE the iPad keyboard from a MODAL view controller?(如何从 MODAL 视图控制器中隐藏 iPad 键盘?)
问题描述
我试图从模态视图控制器中隐藏 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 键盘?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持编程学习网!
本文标题为:如何从 MODAL 视图控制器中隐藏 iPad 键盘?


基础教程推荐
- 从 UIWebView 访问元数据 2022-01-01
- 在视图控制器的宽度上水平均匀分布 UIButton 的最简单方法? 2022-01-01
- EditText 中的 setHintTextColor() 2022-01-01
- 在 iOS 7 下 CCMenu 错位 2022-01-01
- 更改 UITableView 部分标题的颜色 2022-01-01
- Firebase 云消息传递令牌未生成 2022-01-01
- UINavigationItem 的持久 rightBarButtonItem 属性 2022-01-01
- iOS4 创建后台定时器 2022-01-01
- Android - 如何在runOnUiThread 中将数据传递给Runnable? 2022-01-01
- UINavigationBar 隐藏按钮文本 2022-01-01