views:

339

answers:

4

In Apple's official Maps app for the iPhone, there is a small 'page curl' button in the lower-right corner. When you press it, the map itself peels back to reveal some options. I would like to duplicate this effect in my own app.

I'm trying to use UIModalTransitionStylePartialCurl (Added in SDK 3.2). In terms of its layout, my app resembles Apple's official Maps app almost exactly. I can easily get the ENTIRE screen to peel back, revealing another view underneath, but I don't want this. I want ONLY the map view to peel back.

In order to create this effect, you must have a UIViewController that will perform the transition. If I set this UIViewController's view to a small subview somewhere on the screen that does not take up the entire screen, I can get just that subview to peel back. That's great! However, after the second part of the transition (when the page falls back into place), the views are never where they started. Either the view that peeled back will have moved from its original position, or the view that was revealed will have expanded to take up the entire screen.

Is there any obvious mistake that I'm making? I would really appreciate any help!

The code I'm using is really simple. It's basically just:

underMapViewController.modalTransitionStyle = UIModalTransitionStylePartialCurl;

[curlableMapViewController presentModalViewController:underMapViewController animated:YES];
+1  A: 

This is from documentation

UIModalTransitionStylePartialCurl

When the view controller is presented, one corner of the current view curls up to reveal the modal view underneath. On dismissal, the curled up page unfurls itself back on top of the modal view. A modal view presented using this transition is itself prevented from presenting any additional modal views. This transition style is supported only if the parent view controller is presenting a full-screen view and you use the UIModalPresentationFullScreen modal presentation style. Attempting to use a different form factor for the parent view or a different presentation style triggers an exception.

Although, I haven't got any exception using other presentations than full screen. I was testing out and i get the same problem as you. I found this, if my parent viewcontroller's view is an imageview and i set the content mode to UIViewContentModeCenter the view is not resized or moved. May be, there is a trick around by saving your current view as an image, put it at the top, make the curl and after your dismiss your modal, rearrange the messed hidden stuff and remove the top image view. I know that it sounds crazy but that is what i would try if I really had to accomplish that requirement.

Hope this helps, Jorge.

Jorge
Thanks! I'll fool around with the technique you suggested and see if I can come up with something that works.
caecus314
A: 

I ran into this problem as well. For me the frame of the parent view wasn't mangled until the modal view was dismissed. So I cached the frame before dismissing then restored it right after.

CGRect frame = controllerWithModal.view.frame;
[controllerWithModal dismissModalViewControllerAnimated:YES];   
controllerWithModal.view.frame = frame;
Cliff W
A: 

Me too had this problem,but i solved it..(dont know its the right way,but its working)

I wanted to had an imageview inside a scrollview,and when the user taps a button inside that scroll view i wanted to curl-up the scroll view and show a tableview in that place. So i placed a tableview behind scrollview and initialy set it to hidden.when the user taps button i did

[UIView beginAnimations:nil context:NULL];
[UIView setAnimationDuration:1];
[UIView setAnimationTransition:UIViewAnimationTransitionCurlUp forView:frontView cache:YES];
[UIView commitAnimations];

after that removed frontview from view. Hope that helps..

Aji
+1  A: 

How about something like this:

    [UIView beginAnimations:@"PartialPageCurlEffect" context:nil];
    [UIView setAnimationDuration:0.3];
    [UIView setAnimationCurve:UIViewAnimationCurveEaseInOut];
    [UIView setAnimationTransition:UIViewAnimationTransitionCurlUp forView:myOldSubViewController.view cache:YES];

    [myOldSubViewController.view addSubview:myNewViewController.view];

    [UIView commitAnimations];

Note: for some views if the views are complex and off-centre there could be artifacts. Changing cache:YES to cache:NO may fix with.

Marius