简体   繁体   English

添加子视图时,UIView的动画停止

[英]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: 在其viewDidAppear方法中,我添加了几种动画方法,这些方法使云层水平“浮动”,例如:

[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. 现在,我有了另一个使用XIB文件创建的子视图。 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. 几个小时后,我的头撞到墙上,看来这是一个iOS模拟器错误。 Everything works ok on device. 在设备上一切正常。

Note for anyone who faces the same problem: 注意任何面临相同问题的人:

OS: Mavericks 10.9.4 操作系统:Mavericks 10.9.4

Xcode: 5.1.1 Xcode:5.1.1

iOS Simulator target: iOS 7.1 iOS模拟器目标:iOS 7.1

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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