我在自定义 UITableViewCell 中有一个 UiTextView。当我选择 TextView 时,键盘就会出现。
但有时会发生奇怪的行为:
键盘出现后,选定的 tableviewCell 未完全显示。有任何想法吗?我花了两天时间解决这个问题,请帮忙。
最佳答案
当键盘显示时,您可以向上移动 View
//Add to viewDidLoad
[[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(keyboardDidShow:) name:UIKeyboardWillShowNotification object:nil];
[[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(keyboardDidHide:) name:UIKeyboardWillHideNotification object:nil];
//Add to View Controller
//Pushes the view up if one of the table forms is selected for editing
- (void) keyboardDidShow:(NSNotification *)aNotification
{
[UIView beginAnimations:nil context:NULL];
[UIView setAnimationDuration:0.25];
self.view.center = CGPointMake(self.view.center.x, self.view.center.y-moveAmount);
[UIView commitAnimations];
isRaised = [NSNumber numberWithBool:YES];
}
//Pushes view back down
- (void) keyboardDidHide:(NSNotification *)aNotification
{
[UIView beginAnimations:nil context:NULL];
[UIView setAnimationDuration:0.25];
self.view.center = CGPointMake(self.view.center.x, self.view.center.y+moveAmount);
[UIView commitAnimations];
isRaised = [NSNumber numberWithBool:NO];
}
关于ios - 键盘出现后选定的 tableviewCell 未完全显示,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/11250204/