こんにちは皆さん、私のアプリに問題があります... View Controller内で、カメラ内のすべての写真を返すカスタムセルを持つCollectionView私のiPhoneのアプリの写真のロール部分。ベストウェイはPHPhotoLibraryを利用して表示するカスタムセルを持つUICollectionViewのカメラロール画像
今、私はカスタムセルのImageViewで写真を表示するためのすべての手順を実行しましたが、今までは問題ありません...私の問題は、写真をスクロールして写真をアップロードすると、遅いとすぐに[GatekeeperXPC] assetsdへ の接続が中断されたかassetsdが25/02/2017 20死んだ
...アプリのクラッシュがログに私は、このエラーをバック与えた後:画像 を作成する [一般]型が不明な形式はエラーです
コレクションビューに写真を表示するための正しい方法を取ったことがありますか?どこで私は間違えましたか?私のアプリがクラッシュするので?
は、あなたがこれは私が使用PHCachingImageManager
- (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;
}
わかりやすくするためにコードの例を教えてください。私は決してPHPを使ったことはありません。ライブラリーはまったく新しいものです – kAiN
それは冗談のようなものです、神様は "おい、私はすでに二隻のボートとヘリコプターをあなたに送りました..."例を見てください! – matt