Reputation: 572
I'm loading a view in my app with the following code:
- (void)showPicker {
ImagePickerViewController *imagePickerView = [[ImagePickerViewController alloc] initWithNibName:@"ImagePickerViewController" bundle:nil];
[self.navigationController presentModalViewController:imagePickerView animated:YES];
}
How can I load it with a curl up/curl down transition?
Thanks in advance,
Yassin
Upvotes: 1
Views: 6321
Reputation: 519
I love these dormant questions. I had a lot of success doing something like this where you use a view transition animation to show the new view and then presentModalViewController in the completionHandler so that your new view is treated as a modal view.
UIView *container = self.view.window;
[self.theNewViewController viewWillAppear:YES];
[UIView transitionWithView:container
duration:kAnimationViewTransition
options:UIViewAnimationOptionTransitionCurlUp
animations:^{
[self.navigationController.view removeFromSuperview];
[container addSubview: self.theNewViewController.view];
}
completion:^(BOOL finished) {
[self presentModalViewController:self.theNewViewController animated:NO];
}
];
Upvotes: 1
Reputation: 1470
This is now easily available in OS 3.2 and above; you do it like this: --
// if the legend button is tapped, curl up the map view to display the legend view underneath.
- (IBAction) legendButtonPressed:(id) sender
{
UIViewController *legend = [[LegendViewController alloc] init];
legend.modalTransitionStyle = UIModalTransitionStylePartialCurl;
legend.modalPresentationStyle = UIModalPresentationFullScreen;
[self presentModalViewController:legend animated:YES];
[legend release];
}
Upvotes: 4
Reputation: 6040
Using the code you showed there, you could set the modalTransitionStyle property of imagePickerView. But, your possible values are (from the SDK documentation):
Your other option requires you to get a lot fancier. Let's assume the navigationController is the the root view controller of the application, and it's stored in a property of your application delegate called navigationController. You could implement the following methods:
- (void)curlInViewController:(UIViewController *)viewController {
self.curledViewController = viewController;
[UIView beginAnimations:@"curlInView" context:nil];
[UIView setAnimationTransition:UIViewAnimationTransitionCurlDown forView:self.window cache:YES];
[self.navigationViewController.view removeFromSuperview];
[self.window addSubview:viewController.view];
[UIView commitAnimations];
}
- (void)curlOutViewController {
[UIView beginAnimations:@"curlOutView" context:nil];
[UIView setAnimationDelegate:self];
[UIView setAnimationDidStopSelector:@selector(animationDidStop:finished:context:)
[UIView setAnimationTransition:UIViewAnimationTransitionCurlUp forView:self.window cache:YES];
[self.curledViewController removeFromSuperview];
[self.window addSubview:navigationController.view];
[UIView commitAnimations];
}
- (void)animationDidStop:(NSString *)animationID finished:(NSNumber *)finished context:(void *)context {
if([animationID isEqualToString:@"curlOutView"]) {
self.curlViewController = nil;
}
}
Upvotes: 7