views:

352

answers:

2

Hi, 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

+2  A: 

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.

GendoIkari
+2  A: 

in iOS4

To present, its something like -

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

To dismiss, use UIViewAnimationOptionTransitionCurlDown.

Peter DeWeese