UICollectionViewCell
いくつかの配色のいずれかを使用して描画されるカスタム背景ビューを持つカスタムがあります。背景ビューの配色は、-(id)initWithFrame:andColourPalette:
ビューのカスタム初期化子で設定されます。
サブクラスに同様のカスタム初期化子がありますがUICustomViewCell
、セルをセットアップするときにこの初期化子を呼び出す方法がわかりませんcellForItemAtIndexPath:
誰でも私がこれを行うのを手伝ってもらえますか? または、この色のディクショナリをセルに渡してサブビューに渡すための代替ソリューションを提供しますか?
詳細を表示するために編集します。
これは、UICollectionView VC にあるものです。
ViewWillAppear で:
[self.collectionView registerClass:[OPOLawCollectionViewCell class] forCellWithReuseIdentifier:CELL_ID];
self.colourPalette = [OPOColourPalette greenyColourPalette];
cellForItemAtIndexPath:
UICollectionViewCell *cell = [collectionView dequeueReusableCellWithReuseIdentifier:CELL_ID forIndexPath:indexPath];
OPOLawCollectionViewCell *lawCell = (OPOLawCollectionViewCell *)cell;
MainLevel *level = self.collectionData[indexPath.row];
lawCell.delegate = self;
lawCell.colourPalette = self.colourPalette;
私のカスタムUICollectionViewCellで
- (id)initWithFrame:(CGRect)frame
{
self = [super initWithFrame:frame];
if (self)
{
// get background view
OPOLawBook *lawBookView = [[OPOLawBook alloc]initWithFrame:CGRectMake(0, 0, 200, 265) andColourPalette:self.colourPalette];
しかし、それは機能しません-プロパティが設定されていないためだと思います。
最後の行をこれに変更すると、正常に動作します。
OPOLawBook *lawBookView = [[OPOLawBook alloc]initWithFrame:CGRectMake(0, 0, 200, 265) andColourPalette:[OPOColorPalette greenyColorPalette]];
ここでカスタム初期化子を使用する必要があると思いますが、それを呼び出す方法、またはどこからかわかりません...
ありがとう