我在 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/