Iphone UIView使用块动画方法为滑入而不是滑出设置动画

Iphone UIView使用块动画方法为滑入而不是滑出设置动画,iphone,animation,uiview,Iphone,Animation,Uiview,我有一个名为geopointView的UIView。我想在按下按钮(myButton)时在主视图框上的UIview中设置幻灯片动画。如果再次按下My按钮,UIview应滑出框架。myButton调用以下方法“optionsCalled” 这里,checkForGeopointViewAnimation是一个全局变量,用于确保不同时调用滑入和滑出 这段代码的问题是UIview以动画方式滑入,但它不以动画方式滑出动作。它只是从主框架中消失。我是否需要在此处使用任何时间,以便在调用add和remove

我有一个名为geopointView的UIView。我想在按下按钮(myButton)时在主视图框上的UIview中设置幻灯片动画。如果再次按下My按钮,UIview应滑出框架。myButton调用以下方法“optionsCalled”

这里,checkForGeopointViewAnimation是一个全局变量,用于确保不同时调用滑入和滑出

这段代码的问题是UIview以动画方式滑入,但它不以动画方式滑出动作。它只是从主框架中消失。我是否需要在此处使用任何时间,以便在调用add和remove UIview函数时有延迟


提前感谢您的帮助

请尝试
[geopointView removeFromSuperview]动画完成后

可能需要调用
[geopointView removeFromSuperview]改为在你的完成栏中?

@amol_subhedar:请把所有对你有帮助的答案都投上一票,以示感谢。
-(void) optionsCalled
{
if (![[self.view subviews] containsObject:geopointView] &&checkForGeopointViewAnimation ==0) {

        [self.view addSubview:geopointView];
        geopointView.frame = CGRectMake(0,430,320,30);
        [UIView animateWithDuration:0.3f 
                         animations:^{
                             geopointView.frame = CGRectMake(0, 350, 100, 80);
                         }
                         completion:^(BOOL finished){
                             checkForGeopointViewAnimation = 1 ;
                         }];

    }
    if ([[self.view subviews] containsObject:geopointView] && checkForGeopointViewAnimation ==1)
    {

        geopointView.frame = CGRectMake(0, 350, 100, 80);
        [UIView animateWithDuration:0.3f 
                         animations:^{
                             geopointView.frame = CGRectMake(0,430,320,30);
                         }
                         completion:^(BOOL finished){
                             checkForGeopointViewAnimation = 0 ;
                         }];

        [geopointView removeFromSuperview];

    }

}