ALAsset Photo Library Poprawa wydajności obrazu przy jego powolnym ładowaniu

Hi mam problem z wyświetlaniem obrazu na moim scrollView.

Na początku tworzę nowy UIImageView z adresem URL zasobu:

-(void) findLargeImage:(NSNumber*) arrayIndex
{
ALAssetsLibraryAssetForURLResultBlock resultblock = ^(ALAsset *myasset)
{
    ALAssetRepresentation *rep;
    if([myasset defaultRepresentation] == nil) {
        return;
    } else {
        rep = [myasset defaultRepresentation];
    }
    CGImageRef iref = [rep fullResolutionImage];
    itemToAdd = [[UIImageView alloc] initWithFrame:CGRectMake([arrayIndex intValue]*320, 0, 320, 320)];
    itemToAdd.image = [UIImage imageWithCGImage:iref];
    [self.scrollView addSubview:itemToAdd];
};
ALAssetsLibraryAccessFailureBlock failureblock  = ^(NSError *myerror)
{
    NSLog(@"Cant get image - %@",[myerror localizedDescription]);
};
NSURL *asseturl = [NSURL URLWithString:[self.photoPath objectAtIndex:[arrayIndex intValue] ]];
ALAssetsLibrary* assetslibrary = [[ALAssetsLibrary alloc] init];
[assetslibrary assetForURL:asseturl 
               resultBlock:resultblock
              failureBlock:failureblock];

}

Gdzie itemToAdd to UIImageView zdefiniuj w interfejsie:

__block UIImageView *itemToAdd;

I scrollView zdefiniuj jako właściwość:

@property (nonatomic, strong) __block UIScrollView *scrollView;

Następnie w moim viewWillAppear robię to:

- (void) viewWillAppear:(BOOL)animated {
    self.scrollView.delegate = self;
    [self findLargeImage:self.actualPhotoIndex];
    [self.view addSubview:self.scrollView];
}

Ale obraz się nie pojawia, czy powinienem odświeżyć self.view po dodaniu obrazu do scrollView, czy powinienem zrobić coś innego?

questionAnswers(2)

yourAnswerToTheQuestion