Guest User

Untitled

a guest
Sep 11th, 2018
101
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. -(void)bindDetails{
  2.            
  3.         NSMutableArray *imageViewCollectionArray = [[NSMutableArray alloc] init];
  4.  
  5.         float xCordinate = 51.0;   
  6.        
  7.         for (int index = 0; index < 2; index++) {      
  8.            
  9.             UIImageView *firstImage = [[UIImageView alloc] init];
  10.             firstImage.frame = CGRectMake(xCordinate, 0, 188, 145);        
  11.             firstImage.tag = index + 1;
  12.            
  13.             UIActivityIndicatorView *actInd = [[UIActivityIndicatorView alloc] initWithActivityIndicatorStyle:UIActivityIndicatorViewStyleGray];
  14.             actInd.frame = CGRectMake(50,50 , 40, 40);
  15.             [actInd setTag:666];
  16.             [firstImage addSubview:actInd];
  17.             [actInd startAnimating];
  18.             [actInd release];
  19.             actInd = nil;
  20.        
  21.            
  22.             [self.view addSubview: firstImage];
  23.  
  24.             [imageViewCollectionArray addObject: firstImage];
  25.  
  26.             [firstImage release];
  27.             firstImage = nil;
  28.             xCordinate = ((xCordinate * index) + 10);
  29.        
  30.         }  
  31.  
  32.  
  33.  
  34.    [NSThread  detachNewThreadSelector:@selector(bindImages:) toTarget:self withObject: imageViewCollectionArray];
  35.  
  36.    
  37. }
  38.  
  39.  
  40. -(void)bindImages:(NSArray *)objCollection{
  41.    
  42.   NSAutoreleasePool *autoreleasePool = [[NSAutoreleasePool alloc] init];   
  43.        
  44.   UIImageView *myImageView = nil;
  45.   NSString *fileName = nil;
  46.            
  47.   for(int index = 0; index < [objCollection count]; index ++)          
  48.    
  49.       myImageView = [[objCollection objectAtIndex:1] index];
  50.       fileName = [[fileNameCollection objectAtIndex: myImageView.tag] retain];
  51.    
  52.    typedef void (^ALAssetsLibraryAssetForURLResultBlock)(ALAsset *asset);
  53.    typedef void (^ALAssetsLibraryAccessFailureBlock)(NSError *error);    
  54.                        
  55.    ALAssetsLibraryAssetForURLResultBlock resultblock = ^(ALAsset *myasset)
  56.   {
  57.      ALAssetRepresentation *rep = [myasset defaultRepresentation];
  58.      CGImageRef iref = [rep fullResolutionImage];
  59.      UIImage *photoLibImage;
  60.  
  61.     if (iref){
  62.                                
  63.     photoLibImage = [UIImage imageWithCGImage:iref scale:[rep scale] orientation:(UIImageOrientation)[rep orientation]];   
  64.    
  65. }
  66.                                    
  67.   CGSize targetSize = CGSizeMake(myImageView.frame.size.width, myImageView.frame.size.height);
  68.    [myImageView setImage:[self imageByScalingProportionallyToSize:targetSize ImageForConvert:photoLibImage]];
  69.    [[myImageView viewWithTag:666] removeFromSuperview];
  70. };
  71.                        
  72.                          
  73.    NSURL *asseturl = [NSURL URLWithString:fileName];
  74.    ALAssetsLibrary* assetslibrary = [[[ALAssetsLibrary alloc] init] autorelease];
  75.    [assetslibrary assetForURL:asseturl  resultBlock:resultblock  failureBlock:failureblock];   
  76.  
  77.    [autoreleasePool release];
  78.    autoreleasePool = nil;
  79.                
  80.   }
  81. }
Add Comment
Please, Sign In to add comment