0

Ipad 用に次の画像のようなページをデザインしたいと考えています。 最初のオブジェクトが他のオブジェクトよりも大きいです!

UICollectionViewController で実装することにし、初めて UICollectionViewController を使用します。知りたいのですが、UICollectionViewController でセルにさまざまなレイアウトを設定できますか? どうすればそれを行うことができますか?

4

1 に答える 1

0

はい、セルにさまざまなレイアウトを設定できます。

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];

于 2013-07-27T05:34:56.667 に答える