找不到官方的API,就自己写了一下,下面是自己写的函数
--获取滚动层当前位置的百分比 function GetScrollViewPercent(scrollView) if scrollView == nil then return end local size = scrollView:getInnerContainerSize() --内容区大小 local pos = scrollView:getInnerContainerPosition() --内容区当前位置 local listSize = scrollView:getContentSize() --列表可见区域大小 local persent = 100 --顶部是100,底部是0,所以用100去减 偏移量只移动左下角,所以最大偏移量=总高度 - 列表可见区域 if size.height-listSize.height > 0 then persent = 100 - math.abs(pos.y/(size.height-listSize.height) *100) end return persent end
PS:其他相关,参考来源:http://www.cocoachina.com/bbs/read.php?tid=231462
我是3.9 依次调用一下代码即在本帧让所有items的位置正确。这个是lua (函数是一样的)的,c++的函数有些事protected的要弄成public。
listCtro:requestDoLayout();
listCtro:doLayout();
listCtro:getInnerContainer():forceDoLayout();
原文链接: https://www.cnblogs.com/mingfuqishi/p/7827267.html
欢迎关注
微信关注下方公众号,第一时间获取干货硬货;公众号内回复【pdf】免费获取数百本计算机经典书籍
原创文章受到原创版权保护。转载请注明出处:https://www.ccppcoding.com/archives/263374
非原创文章文中已经注明原地址,如有侵权,联系删除
关注公众号【高性能架构探索】,第一时间获取最新文章
转载文章受原作者版权保护。转载请注明原作者出处!