Jat*_*ala 3 objective-c uicollectionview
我试图使用集合视图并显示静态图像,但我收到以下错误:
[UICollectionViewCell imageView]:无法识别的选择器发送到实例.
我已经配置了单元格identifire = Cell.
这是我的代码:
- (UICollectionViewCell *)collectionView:(UICollectionView *)collectionView cellForItemAtIndexPath:(NSIndexPath *)indexPath {
static NSString *CellIdentifier = @"Cell";
SSCollectionViewCell *cell = (SSCollectionViewCell *)[collectionView dequeueReusableCellWithReuseIdentifier:CellIdentifier forIndexPath:indexPath];
int imageNumber = indexPath.row % 10;
cell.imageView.image = [UIImage imageNamed:[NSString stringWithFormat:@"Image%d.jpg",imageNumber]];
return cell;
}
Run Code Online (Sandbox Code Playgroud)
这是sscollectionViewCell.h代码
@interface SSCollectionViewCell : UICollectionViewCell
@property (weak) IBOutlet UIImageView *imageView;
@end
Run Code Online (Sandbox Code Playgroud)
这是SSColletionViewCell.m代码
#import "SSCollectionViewCell.h"
@interface SSCollectionViewCell ()
@end
@implementation SSCollectionViewCell
@synthesize imageView;
- (id)initWithFrame:(CGRect)frame
{
self = [super initWithFrame:frame];
if (self) {
// Initialization code
}
return self;
}
@end
Run Code Online (Sandbox Code Playgroud)
任何人都可以建议我犯错的地方.
tha*_*rem 10
更改
[self.collectionView registerClass:[UICollectionViewCell class] forCellWithReuseIdentifier:reuseIdentifier];
Run Code Online (Sandbox Code Playgroud)
至
[self.collectionView registerClass:[SSCollectionViewCell class] forCellWithReuseIdentifier:reuseIdentifier];
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
2848 次 |
| 最近记录: |