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

标签 ios objective-c iphone uicollectionview uicollectionviewlayout

我有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/

相关文章:

用于 Ad Hoc 分发的 XCode 4 的 iPhone 权利问题

iphone - QuartzCore.framework问题

ios - 使用淡入动画呈现模态视图

ios - MFMailComposeViewController canSendMail 总是返回 false

ios7 UIStatusBar 在 UIViewController 下

objective-c - NSBlockOperation 的粒度状态

iphone - iPhone 中行 Tcp/Ip 的 SSL 客户端

ios - UITableViewCell 无法使用 Swift 动态调整大小

ios - UIPopoverPresentationController 未显示在正确的位置

iphone - .nib 文件的多个版本