display image from URL retrieved from ALAsset in iPhone

后端 未结 4 1662
忘掉有多难
忘掉有多难 2020-11-22 12:39

I am using a ALAsset Framework for accessing the files in the device\'s photo gallery.

So far I am able to access the thumbnail and display it.
I want to display

4条回答
  •  时光说笑
    2020-11-22 13:34

         NSURL* aURL = [NSURL URLWithString:@"URL here"];
         
         ALAssetsLibrary *library = [[ALAssetsLibrary alloc] init];
         [library assetForURL:aURL resultBlock:^(ALAsset *asset)
         {
         UIImage  *copyOfOriginalImage = [UIImage imageWithCGImage:[[asset defaultRepresentation] fullScreenImage] scale:0.5 orientation:UIImageOrientationUp];
         
         cell.backgroundView = [[UIImageView alloc] initWithImage:copyOfOriginalImage];
         }
         failureBlock:^(NSError *error)
         {
         // error handling
         NSLog(@"failure-----");
         }];
    

    just provide the UIReferenceURl you got for the image in photolibrary provided above... its just works fine . . .I diplayed it in

    • UIcollectionView cell

      ..if you just wanna display it in a

    • UIImageView

      means

    Change

    cell.backgroundView = [[UIImageView alloc] initWithImage:copyOfOriginalImage];
    

    To

    imageView.image = copyOfOriginalImage;
    

提交回复
热议问题