我在我的应用程序中有一个uiwebview的问题。键盘完全取代了web内容,我无法将其移回原位。还有一个问题,当输入字段时,webview垂直上下反弹。
键盘前之前http://www.306radio.ca/mobile/photo.PNG
键盘后(不能向下滚动)(http://www.306radio.ca/mobile/chat)在http://www.306radio.ca/mobile/photo1.PNG
实现 UIKeyboardDidShowNotification
和 UIKeyboardWillHideNotification
,这样你就可以做Web-view的重新定位。
例子:
- (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];
}