iPhone键盘何时隐藏UITextView?

时间:2011-06-13 15:04:16

标签: iphone ios uitextview

我正在开发一个iPhone应用程序,并试图获得一个简单,可编辑的UITextView工作的横向视图。

两种界面布局都在NIB文件中指定,我成功加载它们并在设备旋转时迁移数据。

然而,横向版本中的UITextView从iPhone键盘“跑开”,无法看到您正在编辑的内容。我不知道为什么会这样做 - 有人可以帮忙吗?

提前致谢!

问题视频:http://www.youtube.com/watch?v=hfWBKBA_KjQ

1 个答案:

答案 0 :(得分:5)

没有一些代码,无法知道你在做什么,但你应该尝试这样的事情:

- (void) animateTextField: (UITextView*) textView up: (BOOL) up
{
    const int movementDistance = 80; // tweak as needed
    const float movementDuration = 0.3f; // tweak as needed

    int movement = (up ? -movementDistance : movementDistance);

    [UIView beginAnimations: @"anim" context: nil];
    [UIView setAnimationBeginsFromCurrentState: YES];
    [UIView setAnimationDuration: movementDuration];
    self.view.frame = CGRectOffset(self.view.frame, 0, movement);
    [UIView commitAnimations];
}

从您认为合适的地方(例如UIKeyboardWillShowNotigication)调用此设置,并且它会为您的视图设置动画以显示文本视图。