转换到键盘可见的模态视图控制器
是否可以在键盘已经可见的情况下呈现我的模态视图控制器?目前,模式的文本视图在加载视图后立即成为第一响应者,这会导致键盘从底部弹出动画。
我希望键盘已经处于模式上并成为其转变的一部分。有什么建议吗?
Is it possible to present my modal view controller with the keyboard already visible? Currently, the modal's text view becomes the first responder as soon as it's view is loaded, which causes the keyboard to animate coming up from the bottom.
I'd like the keyboard to already be on the modal and be a part of it's transition. Any suggestions?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
键盘是一个单独的 UIWindow 对象。它与视图控制器的视图不在同一视图层次结构中。要实现这一点,您必须深入研究键盘窗口的
UIApplication
的windows
属性,并将其默认动画替换为自定义动画。The keyboard is a separate
UIWindow
object. It is not in the same view hierarchy as your view controller's view. To make this happen, you would have to dig around in theUIApplication
'swindows
property for the keyboard window and replace its default animation with a custom animation.您可以尝试将
becomeFirstResponder
代码放入vieWillAppear
中,但这无论如何都不是“正确”的做法。您可能需要用自定义动画替换实际的键盘动画,以强制它立即加载而不向上滚动。
You could try putting the
becomeFirstResponder
code invieWillAppear
, but that isn't the "right" thing to do anyway.You will probably need to replace the actual keyboard animation with a custom animation to force it to load immediately and without scrolling up.