0
Xcode 4.5.2; 다음과 같이 원격 서버에서 이미지를 다운로드합니다.performSelectorOnMainThread가 너무 일찍 호출 됨
- (void)viewDidLoad
{
[super viewDidLoad];
NSOperationQueue *queue = [NSOperationQueue new];
NSInvocationOperation *operation = [[NSInvocationOperation alloc]
initWithTarget:self
selector:@selector(loadImage)
object:nil];
[queue addOperation:operation];
}
- (void)loadImage{
self.theobject = [RemoteQuery loadObjectWithImage:self.imageKey];
[self performSelectorOnMainThread:@selector(displayImage) withObject:nil waitUntilDone:YES];
}
-(void)displayImage{
UIImage *image = [UIImage imageWithData: self.theobject.imageData];
[self.imageView setImage:image];
}
이 정보는 IOS 시뮬레이터에서 정상적으로 작동하지만 장치에서는 작동하지 않습니다. [RemoteQuery loadImage]에서 데이터가로드되기 전에 displayImage가 호출 된 것처럼 보입니다. 이미지를 표시하기 전에 제대로로드되었는지 확인하는 가장 좋은 방법은 무엇입니까?
위임 프로토콜을 사용하고 있습니다. 감사합니다! –