title: Delay On IPad When Calling From A Background Thread
body: <p>I am converting my IPhone app to IPad and I'm having an issue with the conversion. I have a background thread that creates some thumbnails. </p>
  
  <p>The problem seems to be that the app loops though the array and outputs all the items but only the last item seems to be loading with the UIButton text present. There is a 5-15 second delay before all the previous buttons have there text displayed.</p>
  
  <pre><code>UIImage *tmp = [self thumbnailImage:[effect objectAtIndex:0] thumbnailType:@"category"];
  
  for (id effect in effectArray) {
  
      UIImage *tmp = [self thumbnailImage:[effect objectAtIndex:0] thumbnailType:@"category"];
  
      dispatch_async(dispatch_get_main_queue(), ^{
  
          UIView *effectView = [[UIView alloc] initWithFrame:CGRectMake(item_x_axis, current_row_height, item_width, item_height)];
  
          UIImageView *imagepreview = [[UIImageView alloc] init];
          [imagepreview setFrame:CGRectMake(20, 20, 100, 100)];
          [imagepreview setImage:tmp];
          imagepreview.contentMode = UIViewContentModeScaleAspectFit;
          imagepreview.layer.shadowColor = [UIColor blackColor].CGColor;
          imagepreview.layer.shadowOffset = CGSizeMake(0, 1);
          imagepreview.layer.shadowOpacity = 1;
          imagepreview.layer.shadowRadius = 2.0;
          imagepreview.clipsToBounds = NO;
          [effectView addSubview:imagepreview];
  
          if([[effect objectAtIndex:3]  isEqualToString:@"iap"]){
  
              UIImageView *buttonPlus = [[UIImageView alloc] init];
              [buttonPlus setFrame:CGRectMake(54, 66, 23, 23)];
              [buttonPlus setImage:[UIImage imageNamed:@"ButtonPlus.png"]];
              [effectView addSubview:buttonPlus];
  
          }
  
          UIButton *button = [UIButton buttonWithType:UIButtonTypeCustom];
          [button addTarget:self action:NSSelectorFromString([effect objectAtIndex:1]) forControlEvents:UIControlEventTouchDown];
          [button setTitle:[effect objectAtIndex:2] forState:UIControlStateNormal];
          button.frame = CGRectMake(0, 0, item_width, item_height);
          button.titleLabel.font = [UIFont systemFontOfSize:11];
          [button setTitleShadowColor:[UIColor blackColor] forState:UIControlStateNormal];
          [button.titleLabel setShadowOffset:CGSizeMake(1.0f, 1.0f)];
          [button setTitleEdgeInsets:UIEdgeInsetsMake(120, 0, 0.0, 0.0)];
          [effectView addSubview:button];
  
  
          [self.viewScrollCategories addSubview:effectView];
  
          button = nil;
  
      });
  
      if(current_items_per_row &lt; 3){
          current_items_per_row++;
          item_x_axis = item_x_axis + item_width;
      }else {
          current_row_height = current_row_height + item_height;
          current_items_per_row = 1;
          item_x_axis = 0;
      }
  
  }
  </code></pre>
  
  <p>Any idea how to solve this issue? it seemed to work fine on the IPhone.</p>
  
  <p><strong>EDIT</strong> </p>
  
  <p>This is the code that is calling the background thread (shortned)</p>
  
  <pre><code>- (void)imagePickerController:( UIImagePickerController *)picker didFinishPickingMediaWithInfo: (NSDictionary *)info {
  
  
  //[self generatingThumbnailMessageShow];
  
  dispatch_async(dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0), ^{
      [self loadAllEffects];
      dispatch_async(dispatch_get_main_queue(), ^{
          [self generatingThumbnailMessageHide];
      });
  });
  
  }
  </code></pre>