Ipad 用に次の画像のようなページをデザインしたいと考えています。
UICollectionViewController で実装することにし、初めて UICollectionViewController を使用します。知りたいのですが、UICollectionViewController でセルにさまざまなレイアウトを設定できますか? どうすればそれを行うことができますか?
Ipad 用に次の画像のようなページをデザインしたいと考えています。
UICollectionViewController で実装することにし、初めて UICollectionViewController を使用します。知りたいのですが、UICollectionViewController でセルにさまざまなレイアウトを設定できますか? どうすればそれを行うことができますか?
はい、セルにさまざまなレイアウトを設定できます。
UICollectionView で、使用するさまざまなセル クラスを登録する必要があります。
[self registerClass:[Class1 class] forCellWithReuseIdentifier:@"Class1"];
[self registerClass:[Class2 class] forCellWithReuseIdentifier:@"Class2"];
次に、データソース デリゲートで次のようにします。
-(UICollectionViewCell *)collectionView:(UICollectionView *)collectionView cellForItemAtIndexPath:(NSIndexPath *)indexPath {
// 2 つのクラスを区別するために使用するロジックは何でも
cell = [collectionView dequeueReusableCellWithReuseIdentifier:@"Class1" forIndexPath:indexPath];
//また
cell = [collectionView dequeueReusableCellWithReuseIdentifier:@"Class2" forIndexPath:indexPath];