UITableView scrollToRow no longer works on iOS 11 right after adding a new row

前端 未结 5 2121
没有蜡笔的小新
没有蜡笔的小新 2021-02-20 12:22

I\'ve noticed a weird UITableView behaviour which only seems to occur on iOS 11 devices.

Right after inserting a new row (changing data source and then calling reloadDat

5条回答
  •  执笔经年
    2021-02-20 13:13

    dispatch_after(dispatch_time(DISPATCH_TIME_NOW, (int64_t)(0.01 * NSEC_PER_SEC)), dispatch_get_main_queue(), ^{
    
        [self.tableView scrollToRowAtIndexPath:indexPath atScrollPosition:UITableViewScrollPositionBottom animated:YES];
    });
    

    Adding a small delay is working in my case.

提交回复
热议问题