Die Zelle imageView in UITableView wird erst angezeigt, wenn sie ausgewählt ist

  1. Hier ist ein video von dem problem: http://youtu.be/Jid0PO2HgcU
  2. Ich habe ein problem, wenn Sie versuchen, um das Bild für den [Zelle Bildansicht] in einer UITableView aus der asset-Bibliothek.

Das Bild wird geladen, aber es erscheint nicht in der Zelle, bis ich touch (wählen Sie), die Zelle. Hier ist mein code, der legt die Bildansicht der Zelle:

//Start loading the image using the image path
NSString *path = [occasion imagePath];

if (path != nil && [path hasPrefix:@"ass"])
{
NSLog(@"photo loaded from assets library");
//testing ALAssestLibrary
ALAssetsLibrary* assetsLibrary = [[ALAssetsLibrary alloc] init];

ALAssetsLibraryAssetForURLResultBlock resultsBlock = ^(ALAsset *asset)
{
    ALAssetRepresentation *representation = [asset defaultRepresentation];
    CGImageRef imageRef = [representation fullResolutionImage]; 
    UIImage *image = [[UIImage alloc] initWithCGImage:imageRef];


    [[cell imageView] setImage:[image imageByScalingAndCroppingForSize:CGSizeMake(36.0, 42.0)]];     

    [image release];
};
ALAssetsLibraryAccessFailureBlock failureBlock = ^(NSError *error){

    NSLog(@"FAILED! due to error in domain %@ with error code %d", error.domain, error.code);
    //This sample will abort since a shipping product MUST do something besides logging a
    //message. A real app needs to inform the user appropriately.
    abort();
};        

//Convert path to an NSUrl
NSURL *url = [NSURL URLWithString:path];


//Get the asset for the asset URL to create a screen image.
[assetsLibrary assetForURL:url resultBlock:resultsBlock failureBlock:failureBlock];
//Release the assets library now that we are done with it.
[assetsLibrary release]; 
}

Dem obigen code ist Teil der:

- (UITableViewCell *)tableView:(UITableView *)tableView
 cellForRowAtIndexPath:(NSIndexPath *)indexPath

Irgendwelche Ideen?

InformationsquelleAutor der Frage Ali | 2012-02-19

Schreibe einen Kommentar