UiViewAnimation 不调用 setAnimationDidStopSelector

Posted

技术标签:

【中文标题】UiViewAnimation 不调用 setAnimationDidStopSelector【英文标题】:UiViewAnimation not call setAnimationDidStopSelector 【发布时间】:2013-12-03 17:31:20 【问题描述】:

我创建了这个动画并通过停止动画进入

[UIView setAnimationDidStopSelector:@selector (TermineAnimazioneGoPointAssignedWithDelay)] ;

当 SetAnimationDidStop 的动画部分没有被调用时...你能告诉我为什么以及我在哪里做错了吗?

这是一路动画:

-(void)setViewStatusGoPointassigned 
    ViewgoPointAssignMessage = [[UIView alloc] initWithFrame:CGRectMake(115, 150, 100, 100) ];
    ViewgoPointAssignMessage.backgroundColor = [UIColor colorWithRed:(77/255.0) green:(108/255.0) blue:(143/255.0) alpha:(1)];
    [ViewgoPointAssignMessage.layer setCornerRadius:10.0f];
    [ViewgoPointAssignMessage.layer setMasksToBounds:YES];

    [UIView animateWithDuration:0.2 animations:^

        ViewgoPointAssignMessage.transform = CGAffineTransformMakeScale(1.05, 1.05);
        ViewgoPointAssignMessage.alpha = 0.8; 
                     completion:^(BOOL finished)

                         [UIView animateWithDuration:2/15.0 animations:^
                             ViewgoPointAssignMessage.transform = CGAffineTransformMakeScale(0.9, 0.9);
                             ViewgoPointAssignMessage.alpha = 0.9; 
                                          completion:^(BOOL finished) 

                                              [UIView animateWithDuration:1/7.5 animations:^
                                                  ViewgoPointAssignMessage.transform = CGAffineTransformIdentity;
                                                  ViewgoPointAssignMessage.alpha = 1.0;  ];


                                           ];
                      ];

    [self.view addSubview:ViewgoPointAssignMessage];
    [UIView setAnimationDidStopSelector:@selector(TermineAnimazioneGoPointAssignedWithDelay)];



-(void)TermineAnimazioneGoPointAssignedWithDelay 
    [self performSelector:@selector(EliminazioneViewAfterDelay) withObject:self afterDelay:0.01];

-(void)EliminazioneViewAfterDelay 
    CGRect endREct;
    endREct = CGRectMake(350 , 0 , 330, 90);
    [UIView beginAnimations:nil context:nil];
    [UIView setAnimationDuration:0.005];
    [UIView setAnimationDelegate:self];
    [UIView setAnimationDidStopSelector:@selector(EliminaAnimazione)];
     ViewgoPointAssignMessage.frame = endREct;
    [UIView commitAnimations];


- (void)EliminaAnimazione 
    [ViewgoPointAssignMessage removeFromSuperview];


【问题讨论】:

【参考方案1】:

首先,回答您的问题。 你可以试试

[UIView animateWithDuration:(NSTimeInterval)duration animations:^(void)animations completion:^(BOOL finished)completion]

并在完成时调用[self TermineAnimazioneGoPointAssignedWithDelay]

其次,[UIView setAnimationDidStopSelector:@selector(TermineAnimazioneGoPointAssignedWithDelay)] 不起作用,因为根据参考,必须在 在调用 beginAnimations:context: 和 commitAnimations 方法之间调用 setAnimationDidStopSelector。由于您的代码不符合此规则,因此该功能也不起作用。

希望它能解释!祝你好运!

【讨论】:

没问题,经常查看文档:-)

以上是关于UiViewAnimation 不调用 setAnimationDidStopSelector的主要内容,如果未能解决你的问题,请参考以下文章

iOS,在滑块值 n 处触发一次 UIViewAnimation?

带有约束的 UIViewAnimation 在 Swift 中不起作用

AVPlayer replaceCurrentItemWithPlayerItem 打破 UIViewAnimation

从枚举类型 'enum UIViewAnimationOption 到不同枚举类型 uiviewanimation 的隐式转换

UIViewAnimation 由属于 UINavigationController 的 UIViewController 完成?

UIViewAnimation 导致从枚举类型隐式转换