title: Why do my UIView animations work okay in iOS 5 but no iOS 4?
body: <p>I have a custom UIView with nested views of type UIImageView, UILabel and UIButton. The view is created in code like this:</p>
  
  <pre><code>- (void)setupView
  {
      popupView = [[UIView alloc] initWithFrame:CGRectMake(-116, -61, 247, 59)];
      popupView.autoresizingMask = 63;
      UIImageView *bgImageView = [[UIImageView alloc] initWithImage:[UIImage imageNamed:@"bubble.png"]];
      bgImageView.autoresizingMask = 63;
      [popupView addSubview:bgImageView];
      [bgImageView release];
  
      textLabel = [[UILabel alloc] initWithFrame:CGRectMake(20, 8, 180, 20)];
      textLabel.autoresizingMask = 63;
      textLabel.font = [UIFont fontWithName:@"DefaultNormal" size:16];
      textLabel.text = @"DYNAMIC TEXT";
      [popupView addSubview:textLabel];
  
      popupButton = [[UIButton buttonWithType:UIButtonTypeCustom] retain];
      [rightAccessoryButton setImage:[UIImage imageNamed:@"btn-tick.png"] forState:UIControlStateNormal];
      popupButton.frame = CGRectMake(208, 8, 32, 32);
      popupButton.autoresizingMask = 63;
      [popupView addSubview:rightAccessoryButton];
  }
  </code></pre>
  
  <p>I've set all their <code>autoresizingMask</code>s to 63 which is basically everything in the ON position (I don't know a better way of doing that except putting all the constants on a huge line of code!). Then when they need to animate the popup, I do this:</p>
  
  <pre><code>- (void)animateIn
  {   
      float pw = 247;
      float ph = 59;
  
      // set the view's initial position
      popupView.frame = CGRectMake(-pw*0.005+8, -ph*0.01-2, pw*0.01, ph*0.01);
      [self addSubview:popupView];
  
      [UIView animateWithDuration:0.12 delay:0.0 options:UIViewAnimationOptionCurveEaseOut|UIViewAnimationOptionLayoutSubviews animations:^(void) {
          popupView.frame = CGRectMake(-pw*0.55+8, -ph*1.1-2, pw*1.1, ph*1.1);
      } completion:^(BOOL finished) {
          [UIView animateWithDuration:0.1 delay:0.0 options:UIViewAnimationOptionLayoutSubviews animations:^(void) {
              popupView.frame = CGRectMake(-pw*0.475+8, -ph*0.95-2, pw*0.95, ph*0.95);
          } completion:^(BOOL finished) {
              [UIView animateWithDuration:0.075 delay:0.0 options:UIViewAnimationOptionLayoutSubviews animations:^(void) {
                  popupView.frame = CGRectMake(-round(pw/2-8), -ph-2, pw, ph);
              } completion:nil];
          }];
      }]; 
  }
  </code></pre>
  
  <p>Bit of a complicated looking animation, but effectively this is the same animation as the mapview callout view animation.</p>
  
  <p>Only thing is, it works perfectly on iOS 5 devices, but on iOS 4 devices, everything is wrong! The label doesn't show at all, the button appears and then flies off shrinking into the top right hand corder, and the background image stretches to the wrong size and in the wrong place.</p>
  
  <p>Anyone else had any problems with animations in iOS 4? Do I have to do things differently than how they are currently in order to get it to work?</p>