- (void)updateFetchRequest {
PHFetchOptions *options = [PHFetchOptions new];
switch (self.imagePickerController.mediaType) {
case QBImagePickerMediaTypeImages:
options.predicate = [NSPredicate predicateWithFormat:@"mediaType == %ld", PHAssetMediaTypeImage];
break;
case QBImagePickerMediaTypeVideos:
options.predicate = [NSPredicate predicateWithFormat:@"mediaType == %ld", PHAssetMediaTypeVideo];
break;
default:
break;
}
self.fetchResult = [PHAsset fetchAssetsInAssetCollection:self.assetCollections[0] options:options];
PHContentEditingInputRequestOptions *editoptions = [[PHContentEditingInputRequestOptions alloc] init];
[editoptions setCanHandleAdjustmentData:^BOOL(PHAdjustmentData *adjustmentData) {
return [adjustmentData.formatIdentifier isEqualToString:AdjustmentFormatIdentifier] && [adjustmentData.formatVersion isEqualToString:@"1.0"];
}];
NSLog(@"fectarray %@",self.fetchResult);
PHImageRequestOptions *option = [PHImageRequestOptions new];
option.networkAccessAllowed = YES;
option.synchronous = YES;
option.version = PHImageRequestOptionsVersionOriginal;
PHAssetCollection *assetCollection = self.assetCollections[0];
__weak __typeof(self) weakSelf = self; // New C99 uses __typeof(..)
dispatch_async(dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0), ^{
NSLog(@"Work Dispatched");
PHAsset *asset;
SyncAlbumNames = [NSString stringWithFormat:@"%@",assetCollection.localizedTitle];
for (int i=0; i<self.fetchResult.count; i++) {
asset = weakSelf.fetchResult[i];
NSLog(@"asset is %@",asset);
[asset requestContentEditingInputWithOptions:editoptions
completionHandler:^(PHContentEditingInput *contentEditingInput, NSDictionary *info) {
NSURL *imageURL = contentEditingInput.fullSizeImageURL;
NSLog (@"imageUrl %@",imageURL);
// [weakSelf getLocalId:[NSString stringWithFormat:@"%@",imageURL]];
[self performSelectorOnMainThread:@selector(getLocalId:)
withObject:[NSString stringWithFormat:@"%@",imageURL]
waitUntilDone:YES];
if(uparray.count == 0){
[arrayAssets addObject:asset];
[newArray addObject:asset];
if(arrayAssets.count !=0){
[dict setValue:[NSArray arrayWithArray:arrayAssets]
forKey:assetCollection.localizedTitle];
NSLog(@"dict count is %lu",(unsigned long)dict.count);
}
[SyncAlbum getArraySubTypes];
NSLog(@"arrayAssets count %d",arrayAssets.count);
NSLog(@"fetchresult count %d",weakSelf.fetchResult.count);
__typeof(weakSelf) strongSelf = weakSelf;
if (strongSelf) {
if(arrayAssets.count + 2 + alcount == strongSelf.fetchResult.count){
[strongSelf SyncAlbums];
}
// When finished call back on the main thread:
dispatch_async(dispatch_get_main_queue(), ^{
// Return data and update on the main thread
// Task 3: Deliver the data to a 3rd party component (always do this on the main thread, especially UI).
});
}
//add count to array asset
}else{
NSLog(@"asset already uploaded");
alcount++;
//asset already upload count here..
}
}];
}
});
}
このメソッドを実行すると、UIがブロックされます。私はSQLiteデータベースを使用しています。誰もこれで私を助けることができますか?iOSの写真フレームワークを使用して画像パスを取得中にUIがブロックされる
updateFetchRequestの呼び出し元はどこですか? – BigOmega