我的表格 View 中有一个自定义单元格,当显示键盘时,我的一些单元格隐藏在键盘后面。
为了解决这个问题,我尝试了以下方法
- (void) textFieldDidBeginEditing:(UITextField *)textField {
CustomCell *cell = (CustomCell*) [[textField superview] superview];
NSIndexPath *indexPath = [self.mySmlMsgTemplatesTbl indexPathForCell:cell];
[self.mySmlMsgTemplatesTbl scrollToRowAtIndexPath:indexPath atScrollPosition:UITableViewScrollPositionTop animated:YES];
// [self.mySmlMsgTemplatesTbl scrollToRowAtIndexPath:[self.mySmlMsgTemplatesTbl indexPathForCell:cell] atScrollPosition:UITableViewScrollPositionTop animated:YES];
}
但是好像不行。
最佳答案
您应该尝试按照我在下面显示的代码进行操作。我没有尝试过,但应该可以。
- (void)textFieldDidBeginEditing:(UITextField *)textField{
CGPoint point = [self.tableView convertPoint:yourtextview.bounds.origin fromView:yourtextview];
NSIndexPath* path = [self.tableView indexPathForRowAtPoint:point];
[self.tableView scrollToRowAtIndexPath:path atScrollPosition:UITableViewScrollPositionTop animated:YES];
}
关于iphone - 键盘隐藏自定义单元格,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/10651009/