最新消息:20210816 当前crifan.com域名已被污染,为防止失联,请关注(页面右下角的)公众号

[部分解决]iOS 9中scrollToRowAtIndexPath定位不准确

iOS crifan 6281浏览 0评论

代码:

                let scrollToIndexPath = NSIndexPath(forRow: scrollToIdx, inSection: 0)
                self.messageTableView.scrollToRowAtIndexPath(scrollToIndexPath, atScrollPosition: UITableViewScrollPosition.Top, animated: false)

但是效果是:

虽然可以滚动,但是实际滚动的位置,不是很精确

往往和我要求滚动到的位置,差一些

设置差好几个

导致要求滚动到最底部,经常没有滚动到最底部,还差几个

scrolltorowatindexpath not working for last row

ios – UITableview scrollToRowAtIndexPath not working for the last row – Stack Overflow

ios – scrollToRowAtIndexPath doesn’t handle the last row properly – Stack Overflow

ios – UItableview scrollToRowAtIndexPath not displaying last row correctly – Stack Overflow

ios6 – iOS UItableview scrollToRowAtIndexPath not working anymore – Stack Overflow

objective c – UITableView scrollToRowAtIndexPath not working for last 4 – Stack Overflow

试试

                dispatchMain_async({
                    self.messageTableView.scrollToRowAtIndexPath(scrollToIndexPath, atScrollPosition: UITableViewScrollPosition.Top, animated: false)
                })

有点效果:

多数情况下,是可以滚动到最底部了,但是有时候无法滚动到最底部。

uitableview – iOS 8 Auto cell height – Can’t scroll to last row – Stack Overflow

感觉和:

                delayDispatchInMainThread(0.1, thingsTodo: {
//                dispatchMain_async({
                    self.messageTableView.scrollToRowAtIndexPath(scrollToIndexPath, atScrollPosition: UITableViewScrollPosition.Top, animated: false)
                })

没啥区别。

目前感觉是:

多数情况,大概十之七八,可以滚动到底部

有时候还是无法滚动到底部

转载请注明:在路上 » [部分解决]iOS 9中scrollToRowAtIndexPath定位不准确

发表我的评论
取消评论

表情

Hi,您需要填写昵称和邮箱!

  • 昵称 (必填)
  • 邮箱 (必填)
  • 网址
90 queries in 0.182 seconds, using 22.09MB memory