objective-c - 将 UITextField 置于 UITableViewCell 顶部

标签 objective-c cocoa-touch ios uitableview uitextfield

我在 UITableViewCell 中有 UITextField。当我点击它时,键盘会遮挡它。我已经尝试过,但不起作用:

-(void) textFieldDidBeginEditing:(UITextField *)textField {
    [[self tableView] scrollRectToVisible:[textField frame] animated:YES];
}

如何通过调出文本字段来避免键盘隐藏文本字段? 谢谢

最佳答案

- (BOOL)textViewShouldBeginEditing:(UITextView *)textField
{
CGPoint pnt = [tblView convertPoint:textField.bounds.origin fromView:textField];
path = [[tblView indexPathForRowAtPoint:pnt] retain];
[tblView scrollToRowAtIndexPath:path atScrollPosition:UITableViewScrollPositionTop animated:YES];
return YES;
}

返回

 -(IBAction)Done:(id)sender
{
[tblView scrollToRowAtIndexPath:[NSIndexPath indexPathForRow:0 inSection:0] atScrollPosition:UITableViewScrollPositionTop animated:YES];
[tvDetail resignFirstResponder];

}

您必须在 xib 的 tableview 属性中将 tableviw 的内容插入设置为 200。

关于objective-c - 将 UITextField 置于 UITableViewCell 顶部,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/6230492/

相关文章:

objective-c - 如何使 objective c 控制台行垂直输出?

iphone - iOS 应用程序可以使用哪些文件?

ios - 在 UITableViewCell 中填充动态图像

ios - (iOS) 从非 ascii 键捕获事件

ios - tableview 不刷新已删除的数据

objective-c - 文档类中的 Applescript 命令

iOS 将图像添加到 TextField

cocoa-touch - 知道要使用哪个MKAnnotation的干净解决方案?

objective-c - 如何重新布局 NSTextView 的内容,以便我的制表符以 4 个字符的宽度绘制

iphone - 为什么 popViewController 每隔一段时间才起作用