如何重新定位Web视图键盘消失后?

时间:2013-03-13 00:57:49

标签: iphone ios html5 uiwebview keyboard

我在我的应用中遇到了uiwebview的问题。键盘完全取代了网页内容,我无法将其移回原位。在webview中垂直上下弹跳时,输入字段时也会出现问题。

键盘之前

Before http://www.306radio.ca/mobile/photo.PNG

键盘后(无法向下滚动)(http://www.306radio.ca/mobile/chatafter http://www.306radio.ca/mobile/photo1.PNG

1 个答案:

答案 0 :(得分:2)

实施 UIKeyboardDidShowNotification UIKeyboardWillHideNotification ,以便您可以重新定位网络视图。

示例:

- (void)viewDidLoad
{

  [[NSNotificationCenter defaultCenter] addObserver:self
                                                 selector:@selector(keyboardWasShown:)
                                                     name:UIKeyboardDidShowNotification
                                                   object:nil];

  [[NSNotificationCenter defaultCenter] addObserver:self
                                                 selector:@selector(keyboardWillHide:)
                                                     name:UIKeyboardWillHideNotification
                                                   object:nil];

}


- (void)keyboardWasShown:(NSNotification *)notification
{
   //align Web-view here
}
- (void)keyboardWillHide:(NSNotification *)notification
{
   //align Web-view here
}

- (void)viewDidUnload
{
    [[NSNotificationCenter defaultCenter] removeObserver:self];
}