【发布时间】:2013-09-21 14:47:42
【问题描述】:
我想使用标签栏控制器上方的 uicollectionview 创建一个画廊。我遇到的问题是,当我连接 uicollectionview 数据源时,我遇到了 SIGABRT 崩溃。但是当我没有连接它时,控制器视图没有显示任何图像。有人知道该怎么做吗?
这是我制作的代码:
- (NSInteger)collectionView:(UICollectionView *)collectionView numberOfItemsInSection:(NSInteger)section{
NSLog(@"stiker : %d", stickers1.count);
return stickers1.count;
}
// The cell that is returned must be retrieved from a call to -dequeueReusableCellWithReuseIdentifier:forIndexPath:
- (UICollectionViewCell *)collectionView:(UICollectionView *)collectionView cellForItemAtIndexPath:(NSIndexPath *)indexPath{
static NSString *identifier = @"Cell";
NSLog(@"indexpath row : %d", indexPath.row);
UICollectionViewCell *cell = [collectionView dequeueReusableCellWithReuseIdentifier:identifier forIndexPath:indexPath];
UIImageView *recipeImageView = (UIImageView *)[cell viewWithTag:100];
recipeImageView.image = [UIImage imageNamed:[stickers1 objectAtIndex:indexPath.row]];
// cell.backgroundView = [[UIImageView alloc] initWithImage:[UIImage imageNamed:@"photo-frame.png"]];
return cell;
}
- (NSInteger)numberOfSectionsInCollectionView:(UICollectionView *)collectionView{
NSLog(@"numberOfSectionsInCollectionView coll : %d, stic : %d", collectionView.numberOfSections, stickers1Collection.numberOfSections);
return collectionView.numberOfSections;
}
我已经在xib中连接了uicollectionview数据源
【问题讨论】:
-
显示数据源方法的代码。
-
@Amar 我已经更新了我的代码
-
这个日志打印的是什么
NSLog(@"stiker : %d", stickers1.count);? -
我只是想查看图片数量,可以拒绝
标签: ios image uitabbarcontroller gallery uicollectionview