UITableView scroll indexPath

2017-12-14  本文已影响20人  ReidWang

有些时候在使用 tableView 时,在界面初始化后,会有滚动到指定某一行的需求,有些时候使用延迟滚动可以实现,但是这并不准确。可以使用 GCD 实现该需求,代码如下:

dispatch_async(dispatch_get_main_queue(), ^{

        [_tableView scrollToRowAtIndexPath:[NSIndexPath indexPathForRow:0 inSection:0]                 atScrollPosition:UITableViewScrollPositionTop animated:YES];

});

上一篇 下一篇

猜你喜欢

热点阅读