2011-09-14 9 views
6

Tengo una UIView llamada geopointView. Quiero animar la diapositiva en este UIview en el marco de vista principal cuando se presiona un botón (myButton). Si se presiona myButton nuevamente, UIview debería deslizarse fuera del cuadro. myButton llama al método siguiente "optionsCalled"UIView anima la diapositiva pero no se desliza utilizando el método de animación en bloque

-(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]; 

    } 

} 

aquí checkForGeopointViewAnimation es una variable global definida para asegurar deslizarse dentro y fuera no son llamados a la vez.

El problema con este código es que UIview se desliza de forma animada pero no anima la acción de deslizamiento. simplemente desaparece del cuadro principal. ¿Debo utilizar aquí el tiempo para retrasar la llamada y agregar y eliminar las funciones de UIview?

Gracias por cualquier ayuda de antemano

Respuesta

5

Trate [geopointView removeFromSuperview]; después de la finalización de la animación

+0

Muchas gracias por señalar que ... – alekhine

+1

@amol_subhedar: Por favor, vote todas las respuestas que le sirvieron como muestra de agradecimiento. – visakh7

4

Tal vez necesita llamar [geopointView removeFromSuperview]; en el bloque de terminación en su lugar?

+0

Gracias por su respuesta .. – alekhine

Cuestiones relacionadas