1
배경이 책꽂이 인 UICollectionView에서 잡지 표지 컬렉션을 레이아웃하려고합니다. 선반 당 2 개의 잡지가 있고 나머지는 스크롤 할 때 보일 수 있기를 바랍니다. 여기에 내 코드가있다 :UICollectionView의 이미지 레이아웃
-(void)viewDidLoad {
UINib *cellNib = [UINib nibWithNibName:@"NibCell" bundle:nil];
[self.collectionView registerNib:cellNib forCellWithReuseIdentifier:@"cvCell"];
self.collectionView.backgroundColor = [UIColor colorWithPatternImage:[UIImage imageNamed:@"shelves.png"]];
}
-(NSInteger)numberOfSectionsInCollectionView:(UICollectionView *)collectionView {
return 1;
NSLog(@"1");
}
-(NSInteger)collectionView:(UICollectionView *)collectionView numberOfItemsInSection:(NSInteger)section {
return [_allEntries count];
NSLog(@"2");
}
-(UICollectionViewCell *)collectionView:(UICollectionView *)collectionView cellForItemAtIndexPath:(NSIndexPath *)indexPath {
RSSEntry *entry = [_allEntries objectAtIndex:indexPath.row];
static NSString *cellIdentifier = @"cvCell";
UICollectionViewCell *cell = [collectionView dequeueReusableCellWithReuseIdentifier:cellIdentifier forIndexPath:indexPath];
UIImageView *titleLabel = (UIImageView *)[cell viewWithTag:100];
UILabel *titleLabel2 = (UILabel *)[cell viewWithTag:200];
NSString *thearticleImage = entry.articleImage;
[titleLabel setImageWithURL:[NSURL URLWithString:entry.articleImage] placeholderImage:[UIImage imageNamed:@"[email protected]"]];
// [titleLabel2 setText:entry.articleTitle];
return cell;
}
나는 collectionView 셀을 만들기 위해 XIB를 사용하고있다.
만이 문제가있는 경우, 잘 보이지만 점점 더 많은 문제가 추가됩니다 당신이 스크롤해야하기 시작, 그들은 아주 하차 :