iOS collectionview最后一行显示不全

//collectionview相关

- (void)setCollectionviewLayout {

UICollectionViewFlowLayout *flow = [[UICollectionViewFlowLayout alloc] init];

[flow setScrollDirection:UICollectionViewScrollDirectionVertical];

//    flow.minimumLineSpacing = 0;

//    flow.minimumInteritemSpacing = 0;

flow.itemSize = CGSizeMake(75, 120);

self.typeCollection = [[UICollectionView alloc] initWithFrame:CGRectMake(15, 0, Screen_Width - 30, Screen_Height) collectionViewLayout:flow];

self.typeCollection.backgroundColor = [UIColor clearColor];

self.typeCollection.delegate = self;

self.typeCollection.dataSource = self;

self.typeCollection.showsHorizontalScrollIndicator = NO;

self.typeCollection.showsVerticalScrollIndicator = NO;

[self.typeCollection registerNib:[UINib nibWithNibName:@"TypeCell" bundle:nil] forCellWithReuseIdentifier:@"TypeCell"];

[self.view addSubview:self.typeCollection];

}

#define Screen_Height [[UIScreen mainScreen] bounds].size.height

设置collectionview 的frame的高是屏幕高

如图,当滑到最下边的时候,最后一行一部分被遮挡

原来是因为collocationview的高度设的不对。。。

iOS collectionview最后一行显示不全_第1张图片

将高度减去导航栏状态栏和tabbar的高度即可。



self.typeCollection = [[UICollectionView alloc]

initWithFrame:CGRectMake(15, 0, Screen_Width - 30, Screen_Height - 49 - 64)

collectionViewLayout:flow];

你可能感兴趣的:(iOS collectionview最后一行显示不全)