2

Here is the view that I created using Storyboard:

enter image description here

Clouds, avatar image button, and other text buttons, etc. are its subviews. In its viewDidAppear method, I added several animation methods which cause the clouds to "float" horizontally, for example:

[UIView animateWithDuration:4.0f
                          delay:0.0f
                        options:(UIViewAnimationOptionAutoreverse | UIViewAnimationOptionRepeat | UIViewAnimationOptionAllowUserInteraction)
                     animations:^{
                         _cloud1.frame = its new frame so that it looks to float horizontally;
                     }
                     completion:nil];

Now I have another subview which I created using a XIB file. It's basically a custom-sized subview which will appear when the avatar image button is tapped (we can think of it as "editing profile screen" in social apps). I added it with this animation block (please note that it justs appear on top of the purple circle, which is actually not removed):

_editProfileViewController = [[EditProfileViewController alloc] initWithNibName:nil bundle:nil];
[self addChildViewController:_editProfileViewController];
[_editProfileViewController didMoveToParentViewController:self];

[UIView transitionWithView:self.view duration:0.3 options:(UIViewAnimationOptionTransitionCrossDissolve) animations:^
{
    [self.view addSubview:_editProfileViewController.view];

} completion:NULL];

enter image description here

Problem: When I do that, all clouds stop animating (while the transition still works).

Any ideas? Thank you.

Thiem Nguyen
  • 6,345
  • 7
  • 30
  • 50
  • Check that you might be removing all animations from layer while disappearing from view. – Alfa Sep 17 '14 at 03:47
  • Looking at the code it feels like you're loading the EditProfileViewController into view and therefore unloading the parent view. Have a look at this thread for an alternative approach: [How to present a half modal view controller...](http://stackoverflow.com/questions/22875155/how-to-present-a-half-modal-view-controller-over-the-top-with-ios-7-custom-trans) – carlodurso Sep 17 '14 at 04:08
  • 1
    @carlodurso I looked at that thread. It seems they do exactly the same thing as mine? And also, I think the superview is not unloaded because it's still visible. – Thiem Nguyen Sep 17 '14 at 07:07

1 Answers1

0

After hours banging my head against the wall, it seems that this is an iOS simulator bug. Everything works ok on device.

Note for anyone who faces the same problem:

OS: Mavericks 10.9.4

Xcode: 5.1.1

iOS Simulator target: iOS 7.1

Thiem Nguyen
  • 6,345
  • 7
  • 30
  • 50