gpt4 book ai didi

ios - UICollectionView Vertical 最后显示一半的单元格

转载 作者:行者123 更新时间:2023-12-01 20:15:19 25 4
gpt4 key购买 nike

我有collectionView。它垂直显示单元格。

在开始时,collectionView 看起来像这样

start of the collectionview
enter image description here

最后它看起来像这样

end of collectionView
enter image description here

所以它最终基本上不会显示整个单元格
集合类的代码是

#import "ViewController.h"

@interface ViewController ()
@property (weak, nonatomic) IBOutlet UICollectionView *collectionView;

@end

@implementation ViewController

- (void)viewDidLoad {
[super viewDidLoad];
// Do any additional setup after loading the view, typically from a nib.

}

- (void)didReceiveMemoryWarning {
[super didReceiveMemoryWarning];
// Dispose of any resources that can be recreated.
}


#pragma mark - CollectionView Datasource

- (NSInteger)numberOfSectionsInCollectionView:(UICollectionView *)collectionView{
return 1;
}

- (NSInteger)collectionView:(UICollectionView *)collectionView numberOfItemsInSection:(NSInteger)section{
return 9;
}

- (UICollectionViewCell *)collectionView:(UICollectionView *)collectionView cellForItemAtIndexPath:(NSIndexPath *)indexPath{
ViewControllerCollectionViewCell *cell = [collectionView dequeueReusableCellWithReuseIdentifier:@"Cell" forIndexPath:indexPath];



return cell;
}
@end

最佳答案

您必须在 Storyboard 中指定单元格大小。

关于ios - UICollectionView Vertical 最后显示一半的单元格,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/36790574/

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