gpt4 book ai didi

ios - 我的收藏查看单元隐藏

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

我正在使用 ScrollView 。在我的 ScrollView 中有收藏 View 。我的收藏 View 最后 3 个元素隐藏在空白区域中。在滚动 ScrollView 时,它们不显示。它们在滚动 CollectionView 时显示。我想在 Scroll ScrollView 上显示所有 Collection Cell。不滚动 CollectionView。

-(NSInteger)numberOfSectionsInCollectionView:
(UICollectionView *)collectionView {

return 1; // The number of sections we want
}
-(NSInteger)collectionView:(UICollectionView *)collectionView
numberOfItemsInSection:(NSInteger)section {

return 5; // the number of cells we want
}

- (UICollectionViewCell *)collectionView:(UICollectionView *)collectionViewd
cellForItemAtIndexPath:(NSIndexPath *)indexPath {

CollectionCell* cell =
[collectionViewd dequeueReusableCellWithReuseIdentifier:@"collectionView2CellIdentifier"
forIndexPath:indexPath]; // Create the cell from the storyboard cell

cell.layer.cornerRadius = 4;
cell.layer.borderWidth = 1;
cell.layer.borderColor = [UIColor grayColor].CGColor;

cell.yellow.layer.cornerRadius=4;
cell.red.layer.cornerRadius=4;


cell.title.text =[titleArray objectAtIndex:indexPath.row];
cell.date.text =[dateArray objectAtIndex:indexPath.row];
cell.incomeText.text =[netIncomeArray objectAtIndex:indexPath.row];
cell.expenseText.text =[netExpenseArray objectAtIndex:indexPath.row];
cell.saving.text =[savingArray objectAtIndex:indexPath.row];
cell.expensePecentageText.text =[expensePercentage objectAtIndex:indexPath.row];
cell.savingPercentage.text =[netProfitPercentage objectAtIndex:indexPath.row];

return cell; // Return the cell
}

- (CGFloat)collectionView:(UICollectionView *) collectionView
layout:(UICollectionViewLayout *) collectionViewLayout
minimumInteritemSpacingForSectionAtIndex:(NSInteger) section {
return 2.0;
}


- (UIEdgeInsets)collectionView:(UICollectionView *)collectionView layout:(UICollectionViewLayout*)collectionViewLayout insetForSectionAtIndex:(NSInteger)section
{
return UIEdgeInsetsMake(2, 2, 2, 2);
}
- (CGSize)collectionView:(UICollectionView *)collectionView layout:(UICollectionViewLayout *)collectionViewLayout sizeForItemAtIndexPath:(NSIndexPath *)indexPath
{

return CGSizeMake(155, 158);

}
[scrollView setContentSize:CGSizeMake(0, expenseButton.frame.origin.y+expenseButton.frame.size.height+collection.frame.size.height+16)];

最佳答案

首先统计collectionview的高度 By :

例如

titleArray.count * 160(158px 单元格高度 + 2px 单元格间距)

然后将这个高度分配给collectionview frame

还将此分配给 ScrollView 内容大小高度。

这肯定会为您解决问题。

关于ios - 我的收藏查看单元隐藏,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/32817059/

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