In iOS selected cell should move to top portion in UITableView

后端 未结 4 523
后悔当初
后悔当初 2020-12-20 07:05

I have more than 20 cells in my custom table view, in execution time 6 cells will be visible. Now i select the 4 th cell means, that 4th cell have to come in first position

4条回答
  •  無奈伤痛
    2020-12-20 07:54

    You can scroll your table view to that cell and you can specify that you want to scroll it on top when you select the cell:

    -(void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath
    {
        [tableView scrollToRowAtIndexPath:indexPath atScrollPosition:UITableViewScrollPositionTop animated:YES];
    }
    

    Hope this is what you are after.

提交回复
热议问题