Jam*_*zio 5 iphone objective-c ios
我有一行collectionview水平滚动。该collectionview工程,但它切断了倒数第二个单元(标记为橙色)和皮革最后一个单元格。

我有 5 个单元格,每个单元格的大小为 166x166。我检查了contentsize的viewlayout,它的宽度是 830,这是正确的,但我无法滚动那么远。
这是 Storyboard 中的设置:

这是collectionview.
#pragma mark Collection View Methods
-(NSInteger)numberOfSectionsInCollectionView:(UICollectionView *)collectionView {
return 1;
}
-(NSInteger)collectionView:(UICollectionView *)collectionView numberOfItemsInSection:(NSInteger)section {
return [array count];
}
-(UICollectionViewCell *)collectionView:(UICollectionView *)collectionView cellForItemAtIndexPath:(NSIndexPath *)indexPath {
UICollectionViewCell *cell = [collectionView dequeueReusableCellWithReuseIdentifier:@"FeaturedCell" forIndexPath:indexPath];
UILabel *label = (UILabel *) [cell viewWithTag: 100];
label.text = [array objectAtIndex:indexPath.row];
[cell.layer setBorderWidth:2.0f];
[cell.layer setBorderColor:[UIColor whiteColor].CGColor];
return cell;
}
Run Code Online (Sandbox Code Playgroud)
新的 IB 视图大小默认值为 600 点。如果您不使用自动布局或其他方法来限制尺寸,框架将延伸到屏幕之外并且不可见。如果这种情况发生在 320 像素宽处,您将丢失 240 点,如果您的单元格宽度为 166 点,则意味着您丢失大约 1 1/2 单元格。关于缺少什么。
确保集合视图具有到超级视图边缘的常量 0 的尾随约束(或其他确保大小匹配的方法,例如与超级视图“相等”宽度)。
| 归档时间: |
|
| 查看次数: |
3594 次 |
| 最近记录: |