0
大家好我有我的應用程序的問題...在我的視圖控制器惠普一個自定義單元格的CollectionView應該返回相機中的所有照片滾動我的iPhone的應用程序圖片的部分。最好的方式利用PHPhotoLibrary在UICollectionView顯示相機膠捲圖像與自定義單元格
現在我已經完成了所有的步驟來顯示自定義單元格中的ImageView中的照片,到現在我沒有問題......我的問題是,當我開始滾動照片時,上傳照片是非常慢後立即應用程序崩潰給我回個錯誤日誌中..
[GatekeeperXPC] 連接到assetsd中斷或assetsd死亡25/02/2017 20: [通用]創建圖像 格式與未知類型是錯誤
你能告訴我,如果我採取了正確的方式在我的收藏視圖中顯示圖片嗎?我哪裏做錯了?因爲我的應用程序崩潰?
感謝大家的幫助,您可以給我
這是我的代碼利用
- (void)viewDidLoad {
[super viewDidLoad];
self.nameTextField.delegate = self;
self.emailTextField.delegate = self;
self.passwordTextField.delegate = self;
self.collectionView.delegate = self;
self.collectionView.dataSource = self;
_collectionView.backgroundColor = [UIColor clearColor];
}
-(void)viewDidAppear:(BOOL)animated {
[super viewDidAppear:animated];
[_nameTextField becomeFirstResponder];
[self queryImage];
}
-(void)queryImage {
PHFetchOptions *fetchOptions = [[PHFetchOptions alloc] init];
PHFetchResult *collection = [PHAssetCollection fetchAssetCollectionsWithType:PHAssetCollectionTypeSmartAlbum subtype:PHAssetCollectionSubtypeSmartAlbumUserLibrary options:fetchOptions];
if (collection.firstObject != nil) {
_photoFound = YES;
_assetCollection = collection.firstObject;
} else {
}
_photoAsset = [PHAsset fetchAssetsInAssetCollection:_assetCollection options:nil];
[_collectionView reloadData];
}
- (CGSize)collectionView:(UICollectionView *)collectionView layout:(UICollectionViewLayout*)collectionViewLayout sizeForItemAtIndexPath:(NSIndexPath *)indexPath {
return CGSizeMake(80,80);
}
-(NSInteger)collectionView:(UICollectionView *)collectionView numberOfItemsInSection:(NSInteger)section {
NSUInteger count = 0;
if (_photoAsset != nil) {
count = [_photoAsset count];
}
return count;
}
- (UICollectionViewCell *)collectionView:(UICollectionView *)cv cellForItemAtIndexPath:(NSIndexPath *)indexPath {
static NSString *reuseIdentifier = @"imageCell";
UPCameraRollCollectionViewCell* cell = [cv dequeueReusableCellWithReuseIdentifier:reuseIdentifier forIndexPath:indexPath];
cell.backgroundColor = [UIColor redColor];
PHAsset *asset = [_photoAsset objectAtIndex:indexPath.item];
PHImageManager *imageManager = [PHImageManager defaultManager];
[imageManager requestImageForAsset:asset targetSize:PHImageManagerMaximumSize contentMode:PHImageContentModeAspectFill options:nil resultHandler:^(UIImage * _Nullable result, NSDictionary * _Nullable info) {
[cell setThumbnailImage:result];
}];
return cell;
}
你能給我一個關於我的代碼的例子來更好地理解嗎?我從來沒有甚至用PHPhotolibrary是完全新的給我 – kAiN
這就像那個笑話,是不是,上帝說:「夥計,我已經給你發兩艘船和一架直升機......」看看文檔!看看這個例子! – matt