В контроллере loadDidLoad вызывается метод с потоком, например:
- (void)viewDidLoad {
[super viewDidLoad];
NSInvocationOperation *operation = [[NSInvocationOperation alloc] initWithTarget:self selector:@selector(loadImages) object:nil];
[self.operationQueue addOperation:operation];
[operation release];
}
Загрузите изображение методом loadImages и покажите его:
- (void) loadImages {
@synchronized (self) {
// download image...
// ...
// and next:
UIImageView *imageView = [imageViews objectAtIndex:currentImageIndex];
[imageView performSelectorOnMainThread:@selector(setNeedsDisplay) withObject:nil waitUntilDone:YES];
[imageView performSelectorOnMainThread:@selector(setImage:) withObject:[UIImage imageWithData:imageData] waitUntilDone:YES];
}
//...
}
, которые работают, если показывать в первый раз, в следующий раз я должен повернуть iphone, чтобы показать изображения.
почему представление не перерисовывается?
я попробовал этот код в соответствии с советами:
// imageButton is a UIView with button, image and label
NSData *imageData = [[HttpClient sharedInstance] getResourceWithCache:thumbPath];
[imageButton performSelectorOnMainThread:@selector(setImage:) withObject:[UIImage imageWithData:imageData] waitUntilDone:YES];
[imageButton performSelectorOnMainThread:@selector(setNeedsDisplay) withObject:nil waitUntilDone:YES];
[imageButton drawRect:imageButton.frame];
но не работают.