I have a UIView called geoinformation. I want to animate a slide in this UIview in the main viewport when a button is clicked (myButton). If myButton is pressed again, the UIview should exit the frame. myButton calls the following optionCalled method
-(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]; } }
here checkForGeopointViewAnimation is a global variable defined to provide simultaneous invocation of inputs and outputs.
The problem with this code is that UIview slides in an animated mode, but does not animate sliding actions. it just disappears from the main frame. Do I need to use any time here to delay the call to add and remove UIview functions?
Thanks for any help in advance.
source share