ios - 键盘显示部分 ios6

标签 ios keyboard ios6

我一直无法解决为什么我的应用程序中的键盘部分出现在屏幕上或根本不出现。 它只是一个简单的 View Controller ;

[self presentViewController:vc_browser animated:YES completion:^{}];

我第一次呈现它时,一切正常。然后我将其关闭

[self dismissModalViewControllerAnimated:NO];

并且当再次(和进一步)展示这个 $#%! happens.Loggin 键盘框架从通知给

2012-12-30 00:40:21.618 test[12080:907] 原始键盘框架 {{160, 443}, {0, 44}}

2012-12-30 00:40:21.619 test[12080:907] 键盘框架转换 {{320, 886}, {0, 88}}

2012-12-30 00:40:21.836 test[12080:907] 原始键盘框架 {{0, 524}, {320, 44}}

2012-12-30 00:40:21.837 test[12080:907] 键盘框架转换 {{0, 1048}, {640, 88}}

在下图中,焦点位于 webView 内(实际上是 google 搜索字段)

如果我将焦点移动到键盘矩形上方的文本字段,则记录为 {{inf, inf}, {0, 0}}

viewWillAppear 和 viewDidAppear 没有实现

呈现的 View Controller 以这种方式加载

_vc = [[VC alloc] initWithNibName:@"VC" bundle:nil];

我已经尝试从其他 xib 或其他 Storyboard加载此 View Controller ,但问题仍然存在。

任何解决此问题的帮助都会很棒。谢谢。

http://i.stack.imgur.com/xBNZt.png

不能发布代表 < 10 的图片

最佳答案

我也遇到了同样的问题。我不知道如何对你的问题发表评论(我还是 Stack Overflow 的新手)所以我提供了目前我所发现的部分答案。仍在研究完整的解决方案。

使用 Xcode 4.5.1,我的应用程序使用 iOS 6。这是一个使用 Core Data 的通用应用程序,iPhone 端运行良好。 iPad 端是 Split View。从 Detail View Controller 中,用户可以在 Split View 上打开一个完整的窗口来显示照片。关闭照片 View 会使您返回到 Split View。

下面的代码说明了如何调用和关闭照片浏览器。

[self presentViewController:photoBrowser animated:YES completion:nil];

[self dismissViewControllerAnimated:YES completion:nil];

当我遇到键盘问题时,照片 View 关闭。

症状:带有 UITextFields 或 UITextViews 的后续 View 不再自动显示键盘或键盘仅部分显示,如您的照片示例所示。我使用 becomeFirstResponder 调出键盘。

[self.noteEdit becomeFirstResponder];

同样奇怪的是,如果我触摸任何 UITextField,那么该 View 中的所有文本字段都会消失。

我已针对此问题打开 Apple 技术支持事件 (TSI)。这是他们在 2012 年 10 月 12 日的回复。

I want to give you an update on your incident. Thank you for sending in your code and the sample database. I have been able to reproduce the issue. It turns out, the text fields disappearing in the detail view controller is a result of the keyboard returning invalid data for UIKeyboardFrameEndUserInfoKey causing your code to set the scroll view frame to an invalid size. I am continuing to search for the root cause of this unexpected keyboard behavior and write back as soon as I have an answer.

我通过显示 UIKeyboardFrameEndUserInfoKey userInfo 值验证了他的回复。

NSLog(@"keyboardEndFrame orig.x=%f orig.y=%f size.w=%f, size.h=%f",
      keyboardEndFrame.origin.x, keyboardEndFrame.origin.y, keyboardEndFrame.size.width, keyboardEndFrame.size.height);

果然,原点 x 和 y 的值都是“inf”。大小值设置为零。

现在我只需要知道这一切的原因。仍在研究中,但我会及时通知您任何 Apple 的回复。到目前为止,这个让我很困惑。

PS...我的应用程序(iPhone 和 iPad)在 iOS 5 中运行良好。

更新 - 2012 年 10 月 17 日:

我的键盘出现问题的原因是我在实现 iOS 6 处理方向的新方式时犯了错误。我已经将我的 Split View Controller 子类化为包括以下内容:

- (NSUInteger)supportedInterfaceOrientations {
return [[self splitViewController] supportedInterfaceOrientations];}

修改后的代码是:

- (NSUInteger)supportedInterfaceOrientations{
return UIInterfaceOrientationMaskPortrait;}

当我的 Apple 技术支持事件回复如下时,有人向我指出了这一点:

I've tracked down the root cause of your keyboard troubles. In SplitController.m, the method supportedInterfaceOrientations calls: [[self splitViewController] supportedInterfaceOrientations]; and returns the value received. However, the splitViewController property of a split view controller is nil as split view controllers insider other split view controllers is not allowed. Thus, the returned value is 0, which is an invalid orientation mask.

我的应用根据堆栈顶部的 View 支持不同的方向类型,但我对 Split View Controller 的编码不正确。

Apple 技术支持团队对我帮助很大。希望这些信息对您有所帮助。

干杯!

关于ios - 键盘显示部分 ios6,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/12893660/

相关文章:

html - 如何将网站离线加载为 iOS 应用程序

regex - 连字符和撇号字符 - 不同语言的相同 ASCII 代码?

ios - iOS 5 上未绘制图表

ios - 应用程序在 IOS 6 上崩溃 - UIViewControllerHierarchyInconsistency

ios - 按日期升序的 Realm 顺序总是失败

iOS 相机问题 (Swift)

iphone - iOS "CABasicAnimation"动画完成后将组件带到原始位置

c++ - Qt - C++ 模拟按键

iphone - iOS 静态单元格、自动滚动和附加工具栏键盘

iOS模拟器忽略了一半的屏幕?