iphone - 键盘隐藏自定义单元格

标签 iphone ios uitableview

我的表格 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/

相关文章:

iphone - 如何在没有 Modal 或 Push 的情况下从一个 UIViewController 到另一个 UIViewController 的编程 segue?

iphone - 以编程方式激活飞行模式?

ios - dateFromString 对于某些值返回 nil

ios - UITableViewCell 样式中使用的默认字体设置是什么?

iPhone 横向 - iOS7 R4 图像资源仅无启动图像

iphone - iPhone (OpenGL ES) 上有 glPolygonMode 替代方案吗?

ios - 输入点击事件不适用于带有 ionic 2 和 angular2 的 IOS 设备

ios - 更改应用程序的 iOS 开发者 ID

ios - 使用自定义按钮重新排序 tableview 单元格

iphone - 如何创建具有可编辑组件的 UITableView?