在看asihttprequest代码时候,无意发现了关于键盘弹出时遮盖页面显示的解决方案,
解决方法如下:
在viewload方法里面注册监听键盘弹出和hide
[[self view] setAutoresizingMask:UIViewAutoresizingFlexibleHeight|UIViewAutoresizingFlexibleWidth];
[[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(keyboardWillShow:) name:UIKeyboardWillShowNotification object:nil];
[[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(keyboardWillHide:) name:UIKeyboardWillHideNotification object:nil];
然后在keyboardWillShow修改页面的大小- 键盘的高度
- (void)keyboardWillShow:(NSNotification *)notification
{
#if __IPHONE_OS_VERSION_MIN_REQUIRED >= __IPHONE_3_2
NSValue *keyboardBoundsValue = [[notification userInfo] objectForKey:UIKeyboardFrameEndUserInfoKey];
#else
NSValue *keyboardBoundsValue = [[notification userInfo] objectForKey:UIKeyboardBoundsUserInfoKey];
#endif
CGRect keyboardBounds;
[keyboardBoundsValue getValue:&keyboardBounds];
UIEdgeInsets e = UIEdgeInsetsMake(0, 0, keyboardBounds.size.height-42, 0);
[[self tableView] setScrollIndicatorInsets:e];
[[self tableView] setContentInset:e];
}
恢复正常页面
- (void)keyboardWillHide:(NSNotification *)notification
{
UIEdgeInsets e = UIEdgeInsetsMake(0, 0, 0, 0);
[[self tableView] setScrollIndicatorInsets:e];
[[self tableView] setContentInset:e];
}