[UIView beginAnimations:@"fadeOut" context:nil];
    [UIView setAnimationDuration:5.0];
    [UIView setAnimationDelegate:self];
    [UIView setAnimationDidStopSelector:@selector(animationStopped)];
    self.alpha = 0.0;
    [UIView commitAnimations];animationStopped一开始就被调用了,然后5秒后又被调用一次??

解决方案 »

  1.   

    你设置了委托就别再手动添加一个委托了,[UIView setAnimationDidStopSelector:@selector(animationStopped)];这句不要。找找动画停止的委托。或者不要这句[UIView setAnimationDelegate:self];
      

  2.   

    去掉[UIView setAnimationDelegate:self]后函数animationStopped不被调用,也不对
      

  3.   

    那你把[UIView setAnimationDidStopSelector:@selector(animationStopped)];这句不要。- (void)animationDidStop:(NSString *)animationID finished:(NSNumber *)finished context:(void *)context;实现这个方法。
      

  4.   

    那就是系统决定调用两次的,不是有个 finished的参数么,我觉得两次调用这个参数应该不同。你根据参数 finished判断吧
      

  5.   

    。。还有这样的事情?你用animateWithDuration:animations:completion:这个吧。仔细用法
    [UIView animateWithDuration:0.2
         animations:^{view.alpha = 0.0;}
         completion:^(BOOL finished){ [view removeFromSuperview]; }];