简体   繁体   中英

UIView's animations stopped when adding a subview

Here is the view that I created using Storyboard:

在此处输入图片说明

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];

在此处输入图片说明

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

Any ideas? Thank you.

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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM