jjzjj

layoutAttributesForElementsInRect

全部标签

iphone - 覆盖 layoutAttributesForElementsInRect : of UICollectionView/PSTCollectionView causes visible cell to reload

我想在iPhone应用程序中模仿SonyXperia中提供的图库应用程序的功能。我的画廊应用程序,图像按日期分组显示在网格中,该部分的第一张照片是其他照片的两倍。放大/缩小时,所有照片都会缩小/放大。我按照LithuT.V的建议使用了PSTCollectionView并创建了自定义布局。在该布局中,我覆盖了-(NSArray*)layoutAttributesForElementsInRect:(CGRect)rect。下面是相同的代码。//calledcontinuouslyastherectchanges-(NSArray*)layoutAttributesForElementsI

ios - 尝试使用自定义布局进行屏幕外 UICollectionViewCells 预渲染

我有一个分页的UICollectionView,每页一个单元格。但是,我的UICollectionViewCells呈现速度很慢(第三方库,那里没有选项)。因此,作为优化,我需要预渲染当前页面左侧和右侧的单元格,以便滚动流畅。我所做的是,在我的自定义UICollectionViewLayout中,在检查应该返回哪些单元格的UICollectionViewLayoutAttributes之前将传递的rect设置为1点,请参见此处:-(NSArray*)layoutAttributesForElementsInRect:(CGRect)rect{CGRectoutsetRect=CGRec

ios - 在 UICollectionViewFlowLayout 问题中覆盖 layoutAttributesForElementsInRect

我想创建一个自定义UICollectionViewFlowLayout来更改标题和单元格在CollectionView中的显示方式。我将UICollectionViewFlowLayout子类化并重写了layoutAttributesForElementsInRect方法,在该方法中我创建了自定义定位的UICollectionViewLayoutAttributes对象。问题是我没有使用[superlayoutAttributesForElementsInRect:(CGRect)rect]来生成UICollectionViewLayoutAttributes,因此我的屏幕是空白的。如

ios - layoutAttributesForSupplementaryViewOfKind 未调用

我正在为UICollectionView编写自定义流布局。我可以看到并滚动单元格。问题是我无法显示节标题的补充View。所以,-(UICollectionViewLayoutAttributes*)layoutAttributesForSupplementaryViewOfKind:(NSString*)kindatIndexPath:(NSIndexPath*)indexPath永远不会被调用。在数据源中这个方法:-(UICollectionReusableView*)collectionView:(UICollectionView*)collectionViewviewForSup

ios - 自定义 UICollectionViewLayout : layoutAttributesForElementsInRect asks for really little rect

我已经创建了自定义布局子类UICollectionViewLayout。它完全按照我的需要工作,但是当集合只有少量元素(如“3”)时,layoutAttributesForElementsInRect方法会询问有关0宽度的矩形的信息。这是我的layoutAttributesForElementsInRect实现的代码:-(NSArray*)layoutAttributesForElementsInRect:(CGRect)rect{NSMutableArray*results=[NSMutableArrayarray];for(UICollectionViewLayoutAttribu

ios - layoutAttributesForElementsInRect 的无限循环

我完全不知道为什么会这样,但无论出于何种原因,我正在使用的CollectionView正在无限循环[UICollectionViewDatalayoutAttributesForElementsInRect:]方法。CollectionView位于我的自定义导航栏内。在我使用此自定义导航栏的一种情况下,一切都按预期进行。在另一种情况下,它会无限循环。我尝试过不在collectionView上设置数据源或委托(delegate)。我已尝试设置数据源和委托(delegate),但为itemsInSection返回了0。我在工作情况下使用自动布局,在工作情况下我正在初始化自定义导航栏。关于发

ios - UICollectionViewLayout layoutAttributesForElementsInRect 和 layoutAttributesForItemAtIndexPath

我正在实现自定义流布局。它有2个主要的重写方法来确定单元格的位置:layoutAttributesForElementsInRect和layoutAttributesForItemAtIndexPath。在我的代码中,调用了layoutAttributesForElementsInRect,但未调用layoutAttributesForItemAtIndexPath。什么决定了哪个被调用?layoutAttributesForItemAtIndexPath在哪里被调用? 最佳答案 layoutAttributesForElement