Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/blackberry/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Cocoa touch 滚动至Popover内TableView中的单元格_Cocoa Touch_Resize_Tableview_Popover_Virtual Keyboard - Fatal编程技术网

Cocoa touch 滚动至Popover内TableView中的单元格

Cocoa touch 滚动至Popover内TableView中的单元格,cocoa-touch,resize,tableview,popover,virtual-keyboard,Cocoa Touch,Resize,Tableview,Popover,Virtual Keyboard,我有一个固定行数的tableView(7)。每行由一个标签+一个文本字段组成 当触摸文本字段时,会显示虚拟键bord,这会导致popover的大小调整,并且对于新的大小,7行中只有4行可见。我想做的是,每当用户触摸一个新的文本字段时,tableview就会滚动到包含它的单元格 我试过了 - (void)textFieldDidBeginEditing:(UITextField *)textField{ CGPoint point = [textField.superview conver

我有一个固定行数的tableView(7)。每行由一个标签+一个文本字段组成

当触摸文本字段时,会显示虚拟键bord,这会导致popover的大小调整,并且对于新的大小,7行中只有4行可见。我想做的是,每当用户触摸一个新的文本字段时,tableview就会滚动到包含它的单元格

我试过了

- (void)textFieldDidBeginEditing:(UITextField *)textField{
    CGPoint point = [textField.superview convertPoint:textField.frame.origin toView:self.tableView];
    NSIndexPath *indexPath = [self.tableView indexPathForRowAtPoint:point];
    NSLog(@"Row %d section %d", indexPath.row, indexPath.section);
    [tableView reloadData];
    [tableView scrollToRowAtIndexPath:indexPath atScrollPosition:UITableViewScrollPositionBottom animated:NO];
}
而且

- (void)textFieldDidBeginEditing:(UITextField *)textField{
    CGPoint point = [textField.superview convertPoint:textField.frame.origin toView:self.tableView];
    CGPoint contentOffset = tableView.contentOffset;
    contentOffset.y += (point.y - self.navigationController.navigationBar.frame.size.height); // Adjust this value as you need
    [tableView setContentOffset:contentOffset animated:YES];
}
但它们都不起作用。正在调用该方法(我已设置委托)。我很确定由于虚拟键盘造成的大小调整,它不能工作,但我不知道我能解决谁的问题


有什么帮助吗?非常感谢

以下内容非常有效

- (void)textFieldDidEndEditing:(UITextField *)textField {

    //  Find the cell displaying this textField and scroll it into the middle of the tableView
    UITableViewCell *cell = (UITableViewCell *)[[textField superview] superview];
    NSIndexPath *cellPath = [self.tableView indexPathForCell:cell];
    [self.tableView scrollToRowAtIndexPath:cellPath atScrollPosition:UITableViewScrollPositionMiddle animated:YES];
}

下面的方法非常有效

- (void)textFieldDidEndEditing:(UITextField *)textField {

    //  Find the cell displaying this textField and scroll it into the middle of the tableView
    UITableViewCell *cell = (UITableViewCell *)[[textField superview] superview];
    NSIndexPath *cellPath = [self.tableView indexPathForCell:cell];
    [self.tableView scrollToRowAtIndexPath:cellPath atScrollPosition:UITableViewScrollPositionMiddle animated:YES];
}