UiViewAnimation不调用setAnimationDidStopSelector

时间:2013-12-03 17:31:20

标签: ios uiview uiviewanimation

我创建了这个动画,然后我通过停止动画输入了

[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 个答案:

答案 0 :(得分:2)

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

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

并在完成时致电[self TermineAnimazioneGoPointAssignedWithDelay]

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

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