Warning: file_get_contents(/data/phpspider/zhask/data//catemap/6/multithreading/4.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中使用照片框架获取图像路径时UI被阻止 -(void)updateFetchRequest{ PHFetchOptions*options=[PHFetchOptions new]; 开关(self.imagePickerController.mediaType){ 案例QBImagePickerMediaType图像: options.predicate=[NSPredicate predicateWithFormat:@“mediaType==%ld”,PHAssetMediaTypeImage]; 打破 案例QBImagePickerMediaType视频: options.predicate=[NSPredicate predicateWithFormat:@“mediaType==%ld”,PHAssetMediaTypeVideo]; 打破 违约: 打破 } self.fetchResult=[PHAsset FetchAssetAssetCollection:self.assetCollections[0]选项:选项]; PHContentEditingInputRequestOptions*editoptions=[[PHContentEditingInputRequestOptions alloc]init]; [editoptions setCanHandleAdjustmentData:^BOOL(PHAdjustmentData*adjustmentData){ 返回[adjustmentData.formatIdentifier IsequalString:AdjustmentFormatIdentifier]&&[adjustmentData.formatVersion IsequalString:@“1.0”]; }]; NSLog(@“fectarray%@”,self.fetchResult); PHImageRequestOptions*选项=[PHImageRequestOptions新建]; option.networkAccessAllowed=是; option.synchronous=是; option.version=PHIMAGERequestOptions版本原始; PhaseSetCollection*assetCollection=self.assetCollections[0]; __弱uuTypeof(self)弱self=self;//新C99使用uuuTypeof(…) 调度异步(调度获取全局队列(调度队列优先级默认为0)^{ NSLog(“已派遣工作”); 阶段集*资产; SyncAlbumNames=[NSString stringWithFormat:@“%@”,assetCollection.localizedTitle]; 对于(inti=0;i_Ios_Multithreading_Grand Central Dispatch - Fatal编程技术网

在iOS中使用照片框架获取图像路径时UI被阻止 -(void)updateFetchRequest{ PHFetchOptions*options=[PHFetchOptions new]; 开关(self.imagePickerController.mediaType){ 案例QBImagePickerMediaType图像: options.predicate=[NSPredicate predicateWithFormat:@“mediaType==%ld”,PHAssetMediaTypeImage]; 打破 案例QBImagePickerMediaType视频: options.predicate=[NSPredicate predicateWithFormat:@“mediaType==%ld”,PHAssetMediaTypeVideo]; 打破 违约: 打破 } self.fetchResult=[PHAsset FetchAssetAssetCollection:self.assetCollections[0]选项:选项]; PHContentEditingInputRequestOptions*editoptions=[[PHContentEditingInputRequestOptions alloc]init]; [editoptions setCanHandleAdjustmentData:^BOOL(PHAdjustmentData*adjustmentData){ 返回[adjustmentData.formatIdentifier IsequalString:AdjustmentFormatIdentifier]&&[adjustmentData.formatVersion IsequalString:@“1.0”]; }]; NSLog(@“fectarray%@”,self.fetchResult); PHImageRequestOptions*选项=[PHImageRequestOptions新建]; option.networkAccessAllowed=是; option.synchronous=是; option.version=PHIMAGERequestOptions版本原始; PhaseSetCollection*assetCollection=self.assetCollections[0]; __弱uuTypeof(self)弱self=self;//新C99使用uuuTypeof(…) 调度异步(调度获取全局队列(调度队列优先级默认为0)^{ NSLog(“已派遣工作”); 阶段集*资产; SyncAlbumNames=[NSString stringWithFormat:@“%@”,assetCollection.localizedTitle]; 对于(inti=0;i

在iOS中使用照片框架获取图像路径时UI被阻止 -(void)updateFetchRequest{ PHFetchOptions*options=[PHFetchOptions new]; 开关(self.imagePickerController.mediaType){ 案例QBImagePickerMediaType图像: options.predicate=[NSPredicate predicateWithFormat:@“mediaType==%ld”,PHAssetMediaTypeImage]; 打破 案例QBImagePickerMediaType视频: options.predicate=[NSPredicate predicateWithFormat:@“mediaType==%ld”,PHAssetMediaTypeVideo]; 打破 违约: 打破 } self.fetchResult=[PHAsset FetchAssetAssetCollection:self.assetCollections[0]选项:选项]; PHContentEditingInputRequestOptions*editoptions=[[PHContentEditingInputRequestOptions alloc]init]; [editoptions setCanHandleAdjustmentData:^BOOL(PHAdjustmentData*adjustmentData){ 返回[adjustmentData.formatIdentifier IsequalString:AdjustmentFormatIdentifier]&&[adjustmentData.formatVersion IsequalString:@“1.0”]; }]; NSLog(@“fectarray%@”,self.fetchResult); PHImageRequestOptions*选项=[PHImageRequestOptions新建]; option.networkAccessAllowed=是; option.synchronous=是; option.version=PHIMAGERequestOptions版本原始; PhaseSetCollection*assetCollection=self.assetCollections[0]; __弱uuTypeof(self)弱self=self;//新C99使用uuuTypeof(…) 调度异步(调度获取全局队列(调度队列优先级默认为0)^{ NSLog(“已派遣工作”); 阶段集*资产; SyncAlbumNames=[NSString stringWithFormat:@“%@”,assetCollection.localizedTitle]; 对于(inti=0;i,ios,multithreading,grand-central-dispatch,Ios,Multithreading,Grand Central Dispatch,我相信 - (void)updateFetchRequest { PHFetchOptions *options = [PHFetchOptions new]; switch (self.imagePickerController.mediaType) { case QBImagePickerMediaTypeImages: options.predicate = [NSPredicate predicateWithFormat:@"me

我相信

- (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..
                }
            }];
        }
    });
}
如果您按住cmd键并单击synchronous,则会显示

option.synchronous = YES;
也设置

// return only a single result, blocking until available (or failure). Defaults to NO

HighQualityFormat
将强制synchronous=true。

嘿。我尝试使其异步,但仍然得到相同的问题。问题已解决。感谢帮助。方法[asset requestContentEditingInputWithOptions:editoptions completionHandler:^(PHContentEditingInput*contentEditingInput,NSDictionary*info){NSURL*imageURL=contentEditingInput.fullSizeImageURL;}];正在阻止UI。我更改了方法,它成功了。谢谢。从哪里调用updateFetchRequest?
PHImageRequestOptionsDeliveryMode