이것은 "레이아웃"일뿐입니다. 즉, viewController와 collectionView를 혼자서 제공해야하고, 다음 세 가지를 마무리하십시오. 나는 REPO에 일부 샘플 코드를 추가 할 것입니다, 당신의 WaterfallViewController.h
#import "UICollectionViewWaterfallLayout.h"
@interface WaterfallViewController : UIViewController <UICollectionViewDataSource, UICollectionViewDelegate, UICollecitonViewDelegateWaterfallLayout>
@property (nonatomic, strong) UICollectionView *collectionView;
@end
에서 그리고 당신의 WaterfallViewController.m의 불편에 대한
- (void)viewDidLoad
{
[super viewDidLoad];
UICollectionViewWaterfallLayout *layout = [[UICollectionViewWaterfallLayout alloc] init];
layout.delegate = self;
layout.columnCount = 2;
layout.itemWidth = 146;
layout.sectionInset = UIEdgeInsetsMake(9, 9, 9, 9);
_collectionView = [[UICollectionView alloc] initWithFrame:self.view.bounds collectionViewLayout:layout];
_collectionView.dataSource = self;
_collectionView.delegate = self;
_collectionView.showsVerticalScrollIndicator = NO;
_collectionView.autoresizingMask = UIViewAutoresizingFlexibleHeight | UIViewAutoresizingFlexibleWidth;
[_collectionView registerClass:[MyCell class] forCellWithReuseIdentifier:@"MyCell"];
[self.view addSubview:self.collectionView];
}
#pragma mark - UICollecitonViewDelegateWaterfallLayout Delegate
- (CGFloat)collectionView:(UICollectionView *)collectionView
layout:(UICollectionViewWaterfallLayout *)collectionViewLayout
heightForItemAtIndexPath:(NSIndexPath *)indexPath
{
// return the height for cell at indexPath.
}
죄송합니다 : 여기
은 예입니다 곧.
Nelson- 컨트롤에 헤더를 추가 할 수있는 방법이 있습니까? –