Programmatically force a UIScrollView to stop scrolling, for sharing a table view with multiple data sources

前端 未结 10 973
醉话见心
醉话见心 2020-12-08 03:04

I have a UITableView whose data source and delegate are switched between a couple of custom data source objects when the user touches a segmented control (think \"Top Paid\"

10条回答
  •  不思量自难忘°
    2020-12-08 03:41

    This worked nicely for me:

    if (self.tableView.isDecelerating) {
            NSArray *paths = [self.tableView indexPathsForVisibleRows];
            [self.tableView scrollToRowAtIndexPath:[paths objectAtIndex:0] atScrollPosition:UITableViewScrollPositionTop animated:NO];
    
        }
    

提交回复
热议问题