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

标签 ios objective-c iphone

我正在使用 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/

相关文章:

iphone - AppStore 中忽略的 UIPrerenderedIcon 设置

ios - 如何在 UITableView Swift 的底部插入一个新行

iphone - CAEmitterLayer - kCAEmitterLayerRectangle 渲染模式?

iphone - Objective-C 中的跟踪路由

ios - 停止向 Apple 发送推送通知以进行传递

iphone - 将基于自定义 View 的 UIBarButtonItem 放置在没有默认水平填充的导航栏中

ios - iOS 6上的应用程序崩溃:找不到符号:___sync_fetch_and_add_4

ios - 我们什么时候应该使用 CATransformLayer?

ios - 在iOS中上传之前如何压缩视频数据

objective-c - 找不到 MediaPlayer/Mediaplayer.h 文件