Ios setContentOffset不滚动我的UITableView

Ios setContentOffset不滚动我的UITableView,ios,objective-c,uitableview,Ios,Objective C,Uitableview,当选定单元格到达UITableView中的最后一个位置时,我尝试将UITableViewCell向上滚动一个UITableViewCell位置 我具有识别UITableView的最后一个可见UItableViewCell的正确逻辑。但是,使UITableView向上滚动一个位置的代码不起作用。这是我写的代码 - (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath {

当选定单元格到达UITableView中的最后一个位置时,我尝试将UITableViewCell向上滚动一个UITableViewCell位置

我具有识别UITableView的最后一个可见UItableViewCell的正确逻辑。但是,使UITableView向上滚动一个位置的代码不起作用。这是我写的代码

- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath
{
    cellSelectedBool = YES;

    cell = (CustomFinishingCell *)[tableView cellForRowAtIndexPath:indexPath]; // error
    [cell.widthTexField becomeFirstResponder];


    // Gets an array of current visible cells in UITableView
    NSArray *visibleCells = [tableView visibleCells];
    NSLog(@"%@", visibleCells);
    // get indexpath of last cell
    UITableViewCell *lastCell = [visibleCells lastObject];
    NSIndexPath *lastCellIndex = [finishingTableView indexPathForCell:lastCell];
    // perform scroll when last visible cell is selected
    if (indexPath.row == lastCellIndex.row) {
        NSLog(@"BIGGER");
        int cellHeight = 44;
        [UIView animateWithDuration:.25 animations:^{
            [finishingTableView setContentOffset:CGPointMake(finishingTableView.contentOffset.x,finishingTableView.contentOffset.y + cellHeight) animated:YES];
        }];
    }
你应使用:

NSIndexPath *rowToSelect;  // assume this exists and is set properly
UITableView *myTableView;  // assume this exists

[myTableView selectRowAtIndexPath:rowToSelect animated:YES scrollPosition:UITableViewScrollPositionNone];
[myTableView scrollToRowAtIndexPath:rowToSelect atScrollPosition:UITableViewScrollPositionNone animated:YES];

我认为您正在尝试向下滚动它(它不能再往下滚动了…)。尝试
finishingTableView.contentOffset.y-cellHeight
好的,这样可以。。。。但是,如果用户在UI键盘上按enter键并且当前位于最后一行,则不会调用DidSelectRowatineXpath。。但是,如果我用手指选择最后一行,它将调用didSelectRowAtIndexPath,然后工作。。。。。
if (indexPath.row == lastCellIndex.row) {
    [finishingTableView scrollToRowAtIndexPath:indexPathatScrollPosition:
        UITableViewScrollPositionNone animated:YES];
}