title: Load photos from JSON one by one
body: <p>I have a JSON service, where I use some photos. I want to make a thumbnail gallery from it:</p>
  
  <pre><code>    -(void)fillPhotos:(NSMutableArray *)json{
      _loadingLabel.alpha=0;
      [SV setScrollEnabled:YES];
      if(json.count&gt;0){
          NSDictionary *json_dictionary=[json objectAtIndex:0]; 
          NSInteger i=0;
          for(i=0;i&lt;[[json_dictionary objectForKey:@"Photos"] count];i++){
          NSDictionary *photosDic =[[json_dictionary objectForKey:@"Photos"] objectAtIndex:i] ;
          NSString *imageUrl = [photosDic objectForKey:@"URI"];
          UIImageView* photo;
          CGRect viewRect;
              if(i % 2){
              viewRect = CGRectMake(164,146*(i/2)+10*(i/2), 146, 146);
              NSLog(@"par");
              }else{
              viewRect = CGRectMake(10,146*(i/2)+10*(i/2), 146, 146);   
                  NSLog(@"impar");
              }
              photo = [[UIImageView alloc] initWithFrame:viewRect];
              photo.image=[UIImage imageWithData: [NSData dataWithContentsOfURL:[NSURL URLWithString: imageUrl]]];
              [SV addSubview:photo];
              SV.contentSize=CGSizeMake(320,146*i+146);
              [SV reloadInputViews];
          }
      }
  }
  </code></pre>
  
  <p>It works Okay, but I have two problems. First I want the view to load photo by photo, so the user don't have to wait for the end ond the cicle to view all the photos at once. Second I want the photo to crop in the center, but just occupy the 146x146 frame. But if I put the Top in contentmode the photo pulls out from his frame.</p>
  
  <p>Can you help me with that?</p>