UIView动画在关闭Modal View后停止工作

Jam*_*mes 5 iphone

我刚刚将我的iPhone 4从iOS 4.2.1升级到4.3.2,再升级到XCode 4.0.2,我遇到了uiview动画的一些奇怪问题.当我第一次启动我的应用程序时,这样的代码执行完美:

        [UIView beginAnimations:@"fadeAlphaIn" context:nil];
    [UIView setAnimationDuration:0.5f];
    viewClue.alpha = 1.0f;
    [UIView commitAnimations];
Run Code Online (Sandbox Code Playgroud)

但是,在解雇了一个演示文稿然后通过标准方法解雇一个模态视图之后:

[self presentModalViewController:more animated:YES];
Run Code Online (Sandbox Code Playgroud)

[self dismissModalViewControllerAnimated:YES];
Run Code Online (Sandbox Code Playgroud)

第一个动画不再有效.例如,viewClue视图只是从alpha = 0跳转到alpha = 1,而不是淡入.同样,其他动画改变其他视图的frame属性只会强制帧从初始值跳转到最终值而不动画.在提出和驳回模态视图之前,这些动画工作正常.

我知道其他人在升级到iOS 4.3.2时遇到了动画问题,但模态视图扰乱动画的方式似乎很奇怪.还有其他人遇到过这个问题吗?关于解决方案的任何想法?我正在考虑将模态视图添加为子视图并将其隐藏并显示为动画,但使用标准模态视图方法将更受欢迎.

谢谢你的帮助,

詹姆士

编辑:一些代码显示应用程序的地图是如何动画的

-(void) viewMapfunc
{
    AudioServicesPlaySystemSound(soundID);
    if(mapvisible){
        [UIView animateWithDuration:0.5 
                              delay:0.1
                            options:UIViewAnimationOptionAllowUserInteraction
                         animations:^{
                             map.frame = CGRectMake(0, 350, 320, 27);
                             mapscroll.frame = CGRectMake(0, 27, 320, 0);
                         }
                         completion:nil];

        mapvisible = NO;
        viewMapLabel.text = @"View Map";
    }else {
        [UIView animateWithDuration:0.5 
                              delay:0.1
                            options:UIViewAnimationOptionAllowUserInteraction
                         animations:^{
                             map.frame = CGRectMake(0, 50, 320, 300);
                             mapscroll.frame = CGRectMake(0, 27, 320, 300);
                         }
                         completion:nil];
        mapvisible = YES;
        viewMapLabel.text = @"Hide Map";
    }
}
Run Code Online (Sandbox Code Playgroud)

Jam*_*mes 0

最后,我只是删除了所有模态视图并以其他方式实现它们。由于某种原因,使用模态视图会弄乱动画。没有意义,但删除它们可以解决问题。如果有人能启发我为什么会发生这种情况,这对于记忆问题可能会有好处......

  • 有谁知道为什么会发生这种情况? (6认同)