2
votes

I'm adapting an existing iPhone app to run on the iPad. In the iPhone version, when the user tapped a toolbar button, I would present a modal view controller with a modalTransitionStyle of UIModalTransitionStyleFlipHorizontal, which made a really nice "card-flipping" animation.

The iPad interface is based on a split view (MGSplitViewController, actually). The toolbar button is on the detail pane, so when I present the modal view controller, it takes up the entire screen and the flip transition makes no sense.

To get the right user interaction, I'd like the modal controller to appear and flip into place only over the detail view controller, leaving the master view controller as is.

Is there any way to do this?

2
@parilogic Unfortunately, that's what I'm doing already: i.e. I'm presenting from the split view controller. The modal controller still covers the whole screen.Bill
Um wait.You have to present it through DetailViewController's instance.parilogic
Neither works. I've tried both the split view controller and the detail view controller. Both take up the entire screen.Bill

2 Answers

10
votes
UIViewController *viewController = [[UIViewController alloc] init];
viewController.modalPresentationStyle = UIModalPresentationCurrentContext;

[self presentViewController:viewController animated:YES completion:nil];
5
votes

Probably you can just add its view as as a subview of DetailViewcontroller and use UIview animation to make it look like modal. Reference to [UIView transitionFromView:toView:duration:options:completion]

EDIT When watching WWDC2010 Video (Session 123 : Building Animation Driven Interfaces), I accidentally came to know that I can do the same transition in different manner. I sample coded and it worked :)

It is to use another very similar API [UIView transitionWithView:duration:options:animations:completion:]

My sample code is as follows

// Within your DetailViewController
[self.view addSubview:self.flipSideView];
[UIView transitionWithView:self.view duration:0.8 options:UIViewAnimationOptionTransitionFlipFromLeft animations:^{} completion:nil];

Yup, that was it. Just add the flip side view as a subview and use transitionWithView:... animation instead of transitionFromView....