【发布时间】:2013-04-06 01:00:12
【问题描述】:
我试图通过UICollectionView 在我的主 iphone 屏幕上仅显示 9 张图片。但是我的显示有问题。我的第一张图片总是重复 2 次(在第 1 行的位置 1 和位置 2)。
我的代码有问题吗?
// Define the number of Cell.
- (NSInteger)collectionView:(UICollectionView *)collectionView numberOfItemsInSection:(NSInteger)section{
return 9; }
// The cell that is returned must be retrieved from a call to -dequeueReusableCellWithReuseIdentifier:forIndexPath:
- (UICollectionViewCell *)collectionView:(UICollectionView *)collectionView cellForItemAtIndexPath:(NSIndexPath *)indexPath{
static NSString *IdCell = @"Cell";
SSCollectionViewCell *cell = (SSCollectionViewCell *) [collectionView dequeueReusableCellWithReuseIdentifier: IdCell forIndexPath: indexPath];
int imageNumber = indexPath.row % 9;
cell.imageView.image = [UIImage imageNamed: [NSString stringWithFormat:@"M2_img_%d@2x.png", imageNumber]];
return cell;
}
【问题讨论】:
-
代码看起来不错...检查你的图片 M2_img_0@2x.png & M2_img_1@2x.png
-
[评论因不准确而被删除]
-
我的图片没问题,而且命名正确... :(
-
解决方案:清理并清除所有项目。
标签: iphone ios uiviewcontroller