파노라마를 표시하기 위해 panoramaGL 프레임 워크를 사용하려고합니다. 서버 측은 큐브 파노라마의 모든면에 대해 여러 타일 이미지를 반환합니다. 그래서 배열에 asyncroniously이 이미지를로드해야하고이 후 나는이 이미지에서 큰 측면 질감을해야 -이 작업의 첫 번째 부분에 대한 코드는 다음과 같습니다GCD를 사용하여 배열에 이미지를 비동기 적으로로드하십시오.
dispatch_async(dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_LOW, 0), ^{
int columnCount;
int rowCount;
NSString *side;
if ([level isEqual: @"3"]) {
columnCount = 1;
rowCount = 1;
} else if ([level isEqual: @"2"]) {
columnCount = 2;
rowCount = 2;
... 여기에 내가 준비 내가 이해하는 방법, 내 배열이로드되었는지 - - 그리고 지금 재치를 작동 할 수있는 URL 문자열은
if (face == PLCubeFaceOrientationFront)
side = @"F";
else if (face == PLCubeFaceOrientationBack)
side = @"B";
가 ... 여기에 내가
self.tileArray = [[NSMutableArray alloc] initWithCapacity:columnCount];
for (int columnIndex = 0; columnIndex < columnCount; columnIndex++) {
for (int rowIndex = 0; rowIndex < rowCount; rowIndex++) {
NSString *tileUrl = [NSString stringWithFormat:@"%d_%d", columnIndex, rowIndex];
NSMutableArray *tileUrlComponents = [NSMutableArray array];
[tileUrlComponents addObject: panoramaData[@"id"]];
[tileUrlComponents addObject: side];
[tileUrlComponents addObject: level];
[tileUrlComponents addObject: tileUrl];
NSString *tileIdString = [tileUrlComponents componentsJoinedByString:@"/"];
NSString *panoramaIdUrlString = [NSString stringWithFormat:@"http://SOMEURL=%@", tileIdString];
NSURL *url = [NSURL URLWithString:panoramaIdUrlString];
NSURLRequest *req = [NSURLRequest requestWithURL:url];
[NSURLConnection sendAsynchronousRequest:req queue:[NSOperationQueue currentQueue] completionHandler:^(NSURLResponse *res, NSData *data, NSError *err) {
UIImage *image = [UIImage imageWithData:data];
dispatch_async(dispatch_get_main_queue(), ^{
NSMutableArray *array = [self.tileArray objectAtIndex:columnIndex];
[array replaceObjectAtIndex:rowIndex withObject:image];
[self.tileArray addObject:array];
});
}];
NSLog(@"The URL for the %@ tile is %@", tileUrl, tileIdString);
}
}
});
주요 질문은 URL 문자열 매개 변수를 준비 매개 변수 그 안에있는 이미지들. 두 번째 질문은 이제 불행히도 빈 배열을 얻는다는 것입니다. 어떤 도움이 필요합니까?
이 질문에 대한 답을 살펴보십시오 시도를 제공합니다 - http://stackoverflow.com/questions/24857150/the-program-f low-going-wrong/24857220? noredirect = 1 # comment38602097_24857220 동일한 기술을 사용해야합니다. 디스패치 그룹을 사용하여 모든 비동기로드가 완료된시기를 알 수 있습니다. – Paulw11