Stall in animation
- by tech74
Hi , I am using this code from this site
http://ramin.firoozye.com/2009/09/29/semi-modal-transparent-dialogs-on-the-iphone/
to show a modal view and remove
it. It displays fine ie drops in from the top but when being removed it stalls
just on its way out just for a fraction of second but its noticeable
how do i get rid of the stall.
The view i am showing is view of a viewcontroller which is a memeber of the parent
viewcontroller so i call methods like this to display
[self showModal:self.modalController.view]
to hide
[self hideModal:self.modalController.view];
(void) showModal:(UIView*) modalView
{
UIWindow* mainWindow = (((SessionTalkAppDelegate*) [UIApplication sharedApplication].delegate).window);
//CGPoint middleCenter = modalView.center;
CGPoint middleCenter = CGPointMake(160, 205);
CGSize offSize = [UIScreen mainScreen].bounds.size;
//CGPoint offScreenCenter = CGPointMake(offSize.width / 2.0, offSize.height * 1.5);
CGPoint offScreenCenter = CGPointMake(offSize.width / 2.0, -100); // start from top
modalView.center = offScreenCenter; // we start off-screen
[mainWindow addSubview:modalView];
// Show it with a transition effect
[UIView beginAnimations:nil context:nil];
[UIView setAnimationDuration:0.3]; // animation duration in seconds
[UIView setAnimationCurve:UIViewAnimationCurveEaseInOut];
modalView.center = middleCenter;
[UIView commitAnimations];
}
// Use this to slide the semi-modal back up.
- (void) hideModal:(UIView*) modalView
{
CGSize offSize = [UIScreen mainScreen].bounds.size;
//CGPoint offScreenCenter = CGPointMake(offSize.width / 2.0, offSize.height * 1.5);
CGPoint offScreenCenter = CGPointMake(offSize.width / 2.0, -100);
[UIView beginAnimations:nil context:modalView];
[UIView setAnimationDuration:0.3];
[UIView setAnimationCurve:UIViewAnimationCurveEaseInOut];
[UIView setAnimationDelegate:self];
[UIView setAnimationDidStopSelector:@selector(hideModalEnded:finished:context:)];
modalView.center = offScreenCenter;
[UIView commitAnimations];
}
(void) hideModalEnded:(NSString *)animationID finished:(NSNumber *)finished context:(void )context
{
UIView modalView = (UIView *)context;
[modalView removeFromSuperview];
//[modalView release];
}