カスタムにプロパティを設定しようとしていますUICollectionViewCell
:
-(UICollectionViewCell *)collectionView:(UICollectionView *)collectionView cellForItemAtIndexPath:(NSIndexPath *)indexPath {
// Setup cell identifier
static NSString *cellIdentifier = @"IgCell";
PAInterestGraphCell *cell = (PAInterestGraphCell *)[collectionView dequeueReusableCellWithReuseIdentifier:cellIdentifier forIndexPath:indexPath];
cell.interestCategory = [self.dataArray objectAtIndex:indexPath.row];
// Return the cell
return cell;
}
PAInterestGraphCell
コード:
@interface PAInterestGraphCell : UICollectionViewCell
@property (atomic, retain) PAInterestCategory *interestCategory;
@end
#import "PAInterestGraphCell.h"
#import "PAScaleView.h"
@implementation PAInterestGraphCell
@synthesize interestCategory;
- (id)initWithFrame:(CGRect)frame
{
self = [super initWithFrame:frame];
if (self) {
// Initialization code
PAScaleView *scaleView = [[PAScaleView alloc] initWithFrame:frame];
scaleView.backgroundColor = [UIColor clearColor];
scaleView.interestCategory = self.interestCategory;
[self.contentView addSubview:scaleView];
}
return self;
}
/*
// Only override drawRect: if you perform custom drawing.
// An empty implementation adversely affects performance during animation.
- (void)drawRect:(CGRect)rect
{
// Drawing code
}
*/
@end
しかし、そのinterestCategory
プロパティにアクセスすると、initWithFrame
すべての値が失われました。
ここで明らかな何かが欠けていますか?