关闭时,横向 iPad 上带有键盘的模态视图控制器会更改位置 [英] Modal View Controller with keyboard on landscape iPad changes location when dismissed

查看:31
本文介绍了关闭时,横向 iPad 上带有键盘的模态视图控制器会更改位置的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在 iPad 上使用 UIModalPresentationFormSheet 演示样式和 UIModalTransitionStyleCoverVertical 过渡样式在我的 iPad 上展示了一个模态视图控制器.模态视图控制器包含一个 UIWebView,上面有一些 TextField.当用户点击其中一个文本字段时,键盘就会出现.

I present a modal view controller on my on my iPad with UIModalPresentationFormSheet presentation style and UIModalTransitionStyleCoverVertical transition style. The Modal View Controller contains a UIWebView with some TextFields on it. When the user taps one of the text fields the keyboard comes up.

我注意到,在显示键盘后的横向模式下,如果我尝试关闭带有动画的模态视图控制器,视图会在动画开始之前将其位置从屏幕中心更改为左侧..

I have noticed that in landscape mode after the keyboard is shown, if I try to dismiss the modal view controller with animation the view changes its position from the center of the screen to the left side just before the animation starts..

只有在 iPad 上的键盘向上且仅处于横向模式时才会发生这种情况.如果用户在没有按下任何文本字段的情况下关闭了模态视图,则不会发生这种情况.

This happens only if the keyboard is up and only in landscape mode on the iPad. If the user closes the modal view without pressing on any text field this doesn't happen.

有人熟悉这种奇怪的行为吗?

Anyone familiar with this strange behavior?

推荐答案

我刚刚找到了解决方案.对当前响应者调用 resignFirstResponder,然后调用dismissModalViewControllerAnimated".

I just found a solution to this. Call resignFirstResponder on the current responder and then call dismissModalViewControllerAnimated".

绝对是 iOS 的一个错误,但这对我有用.

Definitely a bug with iOS but this works for me.

这篇关于关闭时,横向 iPad 上带有键盘的模态视图控制器会更改位置的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆