我正在尝试在我的自定义上设置一个属性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
它已经失去了所有的价值。
我在这里遗漏了一些明显的东西吗?