gpt4 book ai didi

ios - UICollectionView 自定义布局问题与 layoutAttributesForElementsInRect :rect

转载 作者:行者123 更新时间:2023-11-29 12:43:03 25 4
gpt4 key购买 nike

在我的使用中

- (NSArray *)layoutAttributesForElementsInRect:(CGRect)rect

在自定义布局子类中,我只看到大部分是 1024 的倍数的矩形坐标值。这是对的吗?我做错了什么?

以下是我在宽度为 3780、高度为 3310 的 UICollectionView 中滚动时看到的值,对于 rect(已删除重复项):

 rect {{0, 0}, {1024, 1024}}
rect {{0, 0}, {2048, 1024}}
rect {{0, 0}, {2048, 2048}}
rect {{0, 1024}, {2048, 1024}}
rect {{0, 1024}, {2048, 2048}}
rect {{0, 2048}, {2048, 1024}}
rect {{0, 2048}, {2048, 1262}}
rect {{1024, 2048}, {2048, 1262}}
rect {{2048, 2048}, {1732, 1262}}
rect {{2048, 2048}, {1732, 1024}}
rect {{2048, 1024}, {1732, 2048}}
rect {{1024, 1024}, {2048, 2048}}
rect {{1024, 1024}, {2048, 1024}}
rect {{1024, 0}, {2048, 2048}}
rect {{1024, 0}, {1024, 2048}}
rect {{0, 0}, {2048, 2048}}
rect {{0, 0}, {2048, 1024}}
rect {{-1024, 0}, {2048, 1024}}
rect {{-1024, 0}, {2048, 2048}}
rect {{-0, 0}, {1024, 2048}}
rect {{0, 0}, {2048, 2048}}
rect {{1024, 0}, {2048, 2048}}
rect {{2048, 0}, {1732, 2048}}

我希望看到的是原点反射(reflect) contentOffset,并且大小始终为屏幕大小。

有什么想法吗?

两个细节:

我正在 iPad 上进行测试,我在边界更改时使布局无效,这就是为什么在我滚动时调用 layoutAttributesForElementsInRect 的原因。

-(BOOL)shouldInvalidateLayoutForBoundsChange:(CGRect)newBounds
{
return YES;
}

最佳答案

Apple 在 devforums 上对此的回答是遵守他们的文档并返回与 rect 参数相交的任何元素,而不考虑 rect 是否有意义。

关于ios - UICollectionView 自定义布局问题与 layoutAttributesForElementsInRect :rect,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/24396095/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com