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。在展示圖片之前確保圖片加載正確的最佳方法是什麼?
得到它與代表協議工作,謝謝! –