Warning: file_get_contents(/data/phpspider/zhask/data//catemap/7/image/5.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
使用UICollectionView iOS创建库_Ios_Image_Uitabbarcontroller_Gallery_Uicollectionview - Fatal编程技术网

使用UICollectionView iOS创建库

使用UICollectionView iOS创建库,ios,image,uitabbarcontroller,gallery,uicollectionview,Ios,Image,Uitabbarcontroller,Gallery,Uicollectionview,我想使用选项卡栏控制器上方的uicollectionview创建一个图库。我遇到的问题是,当我连接uicollectionview数据源时,会发生SIGABRT崩溃。但是当我没有连接它时,控制器视图没有显示任何图像。有人知道该怎么做吗 这是我编写的代码: - (NSInteger)collectionView:(UICollectionView *)collectionView numberOfItemsInSection:(NSInteger)section{ NSLog(@"stik

我想使用选项卡栏控制器上方的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数据源

设置项目数

- (NSInteger)collectionView:(UICollectionView *)collectionView numberOfItemsInSection:(NSInteger)section
设置内容 只需添加
UIImageView
UIlabel
并在
cellForItemAtIndexPath
方法中的故事板分配数据中设置这些标记

- (UICollectionViewCell *)collectionView:(UICollectionView *)collectionView cellForItemAtIndexPath:(NSIndexPath *)indexPath{
static NSString *identifier = @"Cell";

UICollectionViewCell *cell = [collectionView dequeueReusableCellWithReuseIdentifier:identifier forIndexPath:indexPath];

UIImageView *ImageView = (UIImageView *)[cell viewWithTag:100];
ImageView.image  = [UIImage imageNamed:[[arrCategoryValue objectAtIndex:indexPath.row] objectForKey:@"image"]];

UILabel *lbl = (UILabel *)[cell viewWithTag:200];
lbl.text = [[arrCategoryValue objectAtIndex:indexPath.row] objectForKey:@"name"];

cell.tag = indexPath.row;
return cell;
}

有关详细信息,您可以转到

显示数据源方法的代码。@Amar我已更新了我的代码打印的日志是什么
NSLog(@“stiker:%d”,stickers1.count)?我只想检查图像计数,它可以被拒绝