我有一个在显示键盘时调用的方法。它正在研究其他观点。不知怎的,TableView向上移动了。
-(void) keyboardDidShow:(NSNotification *) notification {
// -- return if keyboard is still shown
MyManager *sharedManager = [MyManager sharedManager];
if ([sharedManager.keyboardIsShown isEqualToString:@"YES"]) return;
NSDictionary* info = [notification userInfo];
//---obtain the size of the keyboard---
NSValue *aValue = [info objectForKey:UIKeyboardFrameEndUserInfoKey];
CGRect keyboardRect = [self.view convertRect:[aValue CGRectValue] fromView:nil];
//---resize the scroll view (with keyboard)---
CGRect viewFrame = [scrollView frame];
viewFrame.size.height -= keyboardRect.size.height;
scrollView.frame = viewFrame;
//---scroll to the current text field---
CGRect textFieldRect = [currentTextField frame];
[scrollView scrollRectToVisible:textFieldRect animated:YES];
sharedManager.keyboardIsShown = @"YES";
}
答案 0 :(得分:4)
设置myTableView.autoresizingMask = 0;
就可以了。