Objective c UICollectionView第一个单元格的加载量大于tvOS上的其他单元格
所以我有一个UICollectionView,这样当焦点改变到一个新的单元格时,单元格中的图像就会展开。但出于某种原因,无论何时UICollectionView加载,第一个单元格都比其余单元格大(请参见下面的屏幕截图)。我怎样才能阻止它这样做 我将图像调焦的代码为:Objective c UICollectionView第一个单元格的加载量大于tvOS上的其他单元格,objective-c,uicollectionview,focus,uicollectionviewcell,tvos,Objective C,Uicollectionview,Focus,Uicollectionviewcell,Tvos,所以我有一个UICollectionView,这样当焦点改变到一个新的单元格时,单元格中的图像就会展开。但出于某种原因,无论何时UICollectionView加载,第一个单元格都比其余单元格大(请参见下面的屏幕截图)。我怎样才能阻止它这样做 我将图像调焦的代码为: - (void)collectionView:(UICollectionView *)collectionView didUpdateFocusInContext:(UICollectionViewFocusUpdateConte
- (void)collectionView:(UICollectionView *)collectionView didUpdateFocusInContext:(UICollectionViewFocusUpdateContext *)context withAnimationCoordinator:(UIFocusAnimationCoordinator *)coordinator {
NSIndexPath *previousIndexPath = context.previouslyFocusedIndexPath;
NSIndexPath *indexPath = context.nextFocusedIndexPath;
TrophyCollectionViewCell *previousCell = (TrophyCollectionViewCell *)[collectionView cellForItemAtIndexPath:previousIndexPath];
TrophyCollectionViewCell *cell = (TrophyCollectionViewCell *)[collectionView cellForItemAtIndexPath:indexPath];
[UIView animateWithDuration:0.3 animations:^{
if (previousCell.trophyImageView != nil) {
previousCell.trophyImageView.transform = CGAffineTransformMakeScale(1.0f, 1.0f);
}
if (cell.trophyImageView != nil) {
cell.trophyImageView.transform = CGAffineTransformMakeScale(1.2f, 1.2f);
}
if (previousCell.resetImageView != nil) {
previousCell.resetImageView.transform = CGAffineTransformMakeScale(1.0f, 1.0f);
}
if (cell.resetImageView != nil) {
cell.resetImageView.transform = CGAffineTransformMakeScale(1.2f, 1.2f);
}
}];
}
除此之外,我没有其他影响单元格大小的代码。我通过设置CGAffineTransformMakeScale(1.0f,1.0f)解决了这个问题用于
didUpdateFocusInText
方法中的先前聚焦和下一聚焦单元格。聚焦管理器从屏幕左上角开始查找第一个聚焦元素,因此较大的元素可能就是接收到聚焦的元素
它可能会更大,因为有属性调整形象什么时候祖先聚焦设置为真