OGeek|极客世界-中国程序员成长平台

标题: iphone - iOS:一个动画后,所有其他 View 开始动画 [打印本页]

作者: 菜鸟教程小白    时间: 2022-12-13 06:45
标题: iphone - iOS:一个动画后,所有其他 View 开始动画

我有一个非常特殊的问题。在我开发的一个 iOS 应用程序中,运行下面的动画后,我发现 UI 的各种其他元素现在只要出现就会动画。

例如,一旦运行下面的这些动画,每次我导航到我的应用程序中的新标签时,所有 UI 元素都会从 iphone 的左上角动画到它们的正确位置。我没有为其他选项卡中的这些 UI 元素指定动画,事实上,即使是我无法访问的元素,例如 iPhone 状态栏中的事件指示器,也会开始自行设置动画。

发生了什么事?为什么只有在执行下面的动画后才会出现这种情况?在运行此动画之前(按下按钮),其他应用程序选项卡中的所有其他 UI 元素在出现时根本没有动画,这是预期的行为。

- (IBAction) btnChosenPostcodeClickedid)sender {

  //prep animations
  startView.alpha = 1.0;
  postcodeView.alpha = 0.0;

  [self.view addSubview:postcodeView];

  [UIView beginAnimations"ChosenPostcodeAnimation01" context:nil];

  [UIView setAnimationDuration:animationSpeed];
  [UIView setAnimationTransition:UIViewAnimationTransitionNone forView:self.view cache:YES];
  [UIView setAnimationDelegate:self]; 
  [UIView setAnimationDidStopSelectorselector(chosenPostCodeFadeoutAnimationDone:finished:context];

  startView.alpha = 0.0;

  [UIView commitAnimations];

}

- (void)chosenPostCodeFadeoutAnimationDoneNSString *)animationID finishedNSNumber *)finished contextvoid *)context {
    //prep animations
    postcodeView.alpha = 0.0;

    [UIView beginAnimations"ChosenPostcodeAnimation02" context:nil];

    [UIView setAnimationDuration:animationSpeed];
    [UIView setAnimationTransition:UIViewAnimationTransitionNone forView:self.view cache:YES];

    CGRect newRect = CGRectMake(42, 157, 239, 180);
    imvBubble.frame = newRect;

    postcodeView.alpha = 1.0;

}



Best Answer-推荐答案


你错过了一个

[UIView commitAnimations];

在 selectedPostCodeFadeoutAnimationDone 中,您所做的一切绝对会成为动画的一部分!

关于iphone - iOS:一个动画后,所有其他 View 开始动画,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/5092991/






欢迎光临 OGeek|极客世界-中国程序员成长平台 (http://sqlite.in/) Powered by Discuz! X3.4