添加新行后,UITableView scrollToRow不再适用于iOS 11 [英] UITableView scrollToRow no longer works on iOS 11 right after adding a new row

查看:200
本文介绍了添加新行后,UITableView scrollToRow不再适用于iOS 11的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我注意到一个奇怪的UITableView行为,它似乎只出现在iOS 11设备上。

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

插入新行后立即(更改数据源然后调用reloadData) , UITableView 在调用 scrollToRow scrollToBottom()时不会滚动到该行方法。

Right after inserting a new row (changing data source and then calling reloadData, UITableView won't scroll to that row when calling scrollToRow or scrollToBottom() method.

在iOS 10或更早版本上执行某些操作时,它可以完美地工作,UITable会像它应该的那样滚动。

When doing the some thing on iOS 10 or earlier version, it works perfectly and UITable scrolls like it's supposed to.

谢谢!

推荐答案

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.

这篇关于添加新行后,UITableView scrollToRow不再适用于iOS 11的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆