How to programmatically have UITableView scroll to a specific section

前端 未结 6 1451
离开以前
离开以前 2021-02-13 20:40

In my calendar app, I want my UITableView to scroll to a specific section based on which date is tapped. Current implementation is below:

- (void)calendarDidDate         


        
6条回答
  •  故里飘歌
    2021-02-13 21:18

    You have to find/calculate the section and row that you want to scroll

    NSInteger row = ??;//you have to find/calculate which row you want to show
    NSInteger section = ??;//you have to find/calculate which row of the sections you want to show
    NSIndexPath *ip = [NSIndexPath indexPathForRow:row inSection:section];
    
    [self.agendaTable scrollToRowAtIndexPath:ip
                            atScrollPosition:UITableViewScrollPositionNone
                                    animated:YES];
    

提交回复
热议问题