Warning: file_get_contents(/data/phpspider/zhask/data//catemap/5/objective-c/26.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
Ios UICollectionView不显示图像_Ios_Objective C_Iphone_Xcode_Uicollectionview - Fatal编程技术网

Ios UICollectionView不显示图像

Ios UICollectionView不显示图像,ios,objective-c,iphone,xcode,uicollectionview,Ios,Objective C,Iphone,Xcode,Uicollectionview,我正在创建一组从手机摄像头中选择的图像。它们正在被存储,但由于某些原因,我无法让它们显示在我的collectionView中 在我的CollectionViewController.m中 - (void)viewDidLoad { [self.photoCollectionView registerClass:[PhotoCell class] forCellWithReuseIdentifier:@"PhotoCell"]; self.assets = [[NSMutabl

我正在创建一组从手机摄像头中选择的图像。它们正在被存储,但由于某些原因,我无法让它们显示在我的collectionView中

在我的CollectionViewController.m中

- (void)viewDidLoad {

    [self.photoCollectionView registerClass:[PhotoCell class] forCellWithReuseIdentifier:@"PhotoCell"];

    self.assets = [[NSMutableArray alloc]init];

    [super viewDidLoad];



- (NSInteger) collectionView:(UICollectionView *)collectionView numberOfItemsInSection:(NSInteger)section
{
    return self.assets.count;
}

- (UICollectionViewCell *) collectionView:(UICollectionView *)collectionView cellForItemAtIndexPath:(NSIndexPath *)indexPath
{
    PhotoCell *cell = (PhotoCell *)[collectionView dequeueReusableCellWithReuseIdentifier:@"PhotoCell" forIndexPath:indexPath];

    ALAsset *asset = self.assets[indexPath.row];
    cell.asset = asset;
    cell.backgroundColor = [UIColor redColor];

    return cell;

}
-(void)imagePickerController:(UIImagePickerController*)picker未使用信息完成PickingMediaWithInfo:(NSDictionary*)信息{

}

在我的光电管里

@interface PhotoCell : UICollectionViewCell

@property (nonatomic,strong) ALAsset *asset;

@end
在我的光电管里

#import "PhotoCell.h"

@interface PhotoCell ()

@property(nonatomic, strong) IBOutlet UIImageView *photoImageView;

@end

@implementation PhotoCell

- (void) setAsset:(ALAsset *)asset
{
    _asset = asset;
    self.photoImageView.image = [UIImage imageWithCGImage:[asset thumbnail]];
}
@end

任何帮助都会很好,谢谢。

看起来您从未在资产可变数组中放入任何内容。你在什么地方这样做吗?对不起,我已经更新了我的问题。错过了你说的“休息”是什么意思?它会崩溃吗?如果收到错误消息,请发布错误消息。是,它会崩溃2015-01-20 21:18:40.150 BabyDiary[2382:115642]-[UIImage缩略图]:发送到实例0x7fe75d09a340 2015-01-20 21:18:40.164 BabyDiary[2382:115642]的无法识别的选择器***由于未捕获的异常“NSInvalidArgumentException”终止应用程序,原因:'-[UIImage缩略图]:无法识别的选择器发送到实例0x7fe75d09a340'***第一次抛出调用堆栈:错误非常明显。您正在调用没有该方法的UIImage上的缩略图。您的资产似乎是一个UIImage,而不是一个集合。
#import "PhotoCell.h"

@interface PhotoCell ()

@property(nonatomic, strong) IBOutlet UIImageView *photoImageView;

@end

@implementation PhotoCell

- (void) setAsset:(ALAsset *)asset
{
    _asset = asset;
    self.photoImageView.image = [UIImage imageWithCGImage:[asset thumbnail]];
}
@end