Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Dismiss modalviewcontroller with a page curl

I am trying to dismiss a modalviewcontroller with a page curl. The curl works okay but I cannot seem to get the tableview under the modalviewcontroller to show up. The image of the modalviewcontroller is still under the curled away page. If I dismiss the modalviewcontoller before the animation finishes the animation doesn't show up. Here is my code:

//hide splash screen
- (void)hideSplash{
 [UIView beginAnimations:nil context:nil];
 //change to set the time
 [UIView setAnimationDuration:2];
 [UIView setAnimationBeginsFromCurrentState:YES];
 [UIView setAnimationTransition:UIViewAnimationTransitionCurlUp forView:modelView cache:NO];
 // do your view swapping here

 //[[self modalViewController] dismissModalViewControllerAnimated:NO];

 [UIView commitAnimations];
//[self.view  sendSubviewToBack:self.view]; 

}

Hope someone can help! Cheers Nick

like image 788
Nick Avatar asked Feb 27 '10 20:02

Nick


2 Answers

In iOS4:

To present, it's something like:

[containerView addSubview:modelView];
[UIView transitionWithView:containerView
                  duration:.75
                   UIViewAnimationOptionTransitionCurlUp
                animations:^{}
                completion:^(BOOL finished) {
                    NSLog(@"finished %d", finished);
                }];

To dismiss, use UIViewAnimationOptionTransitionCurlDown.

like image 106
Peter DeWeese Avatar answered Oct 15 '22 13:10

Peter DeWeese


Your setAnimationTransition: shouldn't be forView:modelView; it should be for the parentView.

[UIView setAnimationTransition:UIViewAnimationTransitionCurlUp forView:containerView cache:NO];

http://developer.apple.com/library/ios/#documentation/uikit/reference/UIView_Class/UIView/UIView.html

If you want to change the appearance of a view during a transition—for example, flip from one view to another—then use a container view, an instance of UIView, as follows:

  • Begin an animation block.
  • Set the transition on the container view.
  • Remove the subview from the container view.
  • Add the new subview to the container view.
  • Commit the animation block.

Use of this method is discouraged in iOS 4.0 and later. You should use the block-based animation methods instead.

like image 3
GendoIkari Avatar answered Oct 15 '22 12:10

GendoIkari