이미지를 표시하는 UICollectionView
이 있습니다. 내 이미지 크기는 114x133이지만 어떤 이유로 실제 UICollectionVewCell
이 이보다 더 큽니다 (셀 배경을 빨간색으로 설정했기 때문에이 사실을 알 수 있습니다). 이 때문에 뷰는 2 개의 이미지 만 표시 할 수 있으며 두 이미지 사이에 큰 차이가 있습니다. 내가 만드는 오전 다음UICollectionView 레이아웃, 멀리 떨어진 셀 간격
- (CGSize)collectionView:(UICollectionView *)collectionView layout:(UICollectionViewLayout*)collectionViewLayout sizeForItemAtIndexPath:(NSIndexPath *)indexPath {
UIImage* img = [UIImage imageNamed:@"thumbnail_frame.png"];
return img.size;
}
- (UIEdgeInsets)collectionView:
(UICollectionView *)collectionView layout:(UICollectionViewLayout*)collectionViewLayout insetForSectionAtIndex:(NSInteger)section {
return UIEdgeInsetsMake(1, 1, 1, 1);
}
를 구현하고있는 세포의 contentview
프로그램 (즉 초기화 imageView
등).
전체보기를 프로그래밍 방식으로 만드는 다른보기에서 동일한 문제가 발생합니다. 거기에 내가 할 : 나는 폭을 작게 만들 경우
UICollectionViewFlowLayout *flowLayout = [[UICollectionViewFlowLayout alloc] init];
flowLayout.minimumInteritemSpacing=10;
flowLayout.minimumLineSpacing= 30;
flowLayout.sectionInset = UIEdgeInsetsMake(5, 5, 5, 5);
if(collectionView != nil) {
[collectionView removeFromSuperview];
}
CGRect frm= CGRectMake(45, 80, 250, 230);
collectionView = [[UICollectionView alloc] initWithFrame:frm collectionViewLayout:flowLayout];//(0, 0, self.view.frame.size.width, self.view.frame.size.height) collectionViewLayout:flowLayout];
collectionView.backgroundColor = [UIColor colorWithRed:0 green:0 blue:0 alpha:0.5];
collectionView.clipsToBounds = YES;
collectionView.layer.cornerRadius = 10.0;
collectionView.dataSource = self;
collectionView.delegate = self;
[collectionView registerClass:[YourPicCollectionViewCell class] forCellWithReuseIdentifier:@"YourPicCell"];
을 다시 두 이미지 사이에 큰 차이 중 하나가, 나,이 3 개 이미지하지만 가장 오른쪽 한 반 볼 수 있습니다.
필자는 간격을 두지 만 작동하지 않는 것 같습니다. 무엇이 문제 일 수 있습니까?