views:

4407

answers:

5

I am looking for a way to do a UIViewAnimationTransitionCurlUp or UIViewAnimationTransitionCurlDown transition on the iPhone but instead of top to bottom, do it from the left to right (or top/bottom in landscape mode). I've seen this asked aroud the internet a few times but none sems to get an answer. However I feel this is doable.

I have tried changing the View's transform and the view.layer's transform but that didn't affect the transition. Since the transition changes when the device changes orientation I presume there is a way to fool the device to use the landscape transition in portrait mode and vice versa?

A: 

I don't think there is a way beyond writing a custom animation.

More importantly you probably shouldn't try to it. The curl up and curl down are part of the user interface grammar that tells the user that a view is being lifted up or put down over the existing view. It's supposed to be like a sticky note being put down and then removed. A left<->right curl will most likely be interpreted as the something like ripping a page out of a book. It will confuse users.

Whenever you find yourself trying to do something in the interface that the standard API doesn't do easily, you should ask yourself whether such a novel method will communicate something important to user and whether it is similar to the existing interface grammar. If not, then you shouldn't bother.

Unusual interfaces have an initial wow factor but they lead to frustration and errors in day-to-day use. They can also cause Apple to refuse your app.

TechZen
It's not unusual. It's exactly the same. In fact Apple does it, just in the opposite orientation. I am creating an interactive landscape book so I am positive that this animation will communicate the book-feeling to the user. The up-down effect works for notebooks (like notes app). But for a proper book I need a different feeling.
Dimitris
If you look at the curl transition, you will see that it detaches three corners of the view. A turned page only detaches two. The curl moves the view diagonally while a page turn moves only left-to-right. The difference is subtle but important to user expectations.
TechZen
I don't think you can get the transition you want by a simple transform because the primary motion in the curl transition is the diagonal motion of the bottom-right corner. No matter how you rotate or transform the view, that diagonal motion will remain which will destroy the illusion of a simple left-to-right curl.
TechZen
+2  A: 

I actually managed to achieve this effect by changing the orientation of my UIViewController. The strange thing is, I had my controller nesten in another one when it wasn't working, but when I set him as the immediate view controller, it worked.

Code that does it:

In a UIViewController that is the main view controller in my app delegate and only allows landscape orientation (as you see in the 2nd method below) I have the following:

-(void)goToPage:(int)page flipUp:(BOOL)flipUp {

     //do stuff...

     // start the animated transition
     [UIView beginAnimations:@"page transition" context:nil];
     [UIView setAnimationDuration:1.0];
     [UIView setAnimationTransition:flipUp ? UIViewAnimationTransitionCurlUp : UIViewAnimationTransitionCurlDown forView:self.view cache:YES];

     //insert your new subview
     //[self.view insertSubview:currentPage.view atIndex:self.view.subviews.count];

      // commit the transition animation
      [UIView commitAnimations];
}

- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation {
     return (interfaceOrientation == UIInterfaceOrientationLandscapeRight);
}
Dimitris
What about status bar ? - status bar will look on the right side - when using application ?
sugar
This doesn't seem to work.
adib
Make sure your View Controller is not nested, or if it is make sure its parents are implementing the right orientation...
Dimitris
A: 

could you post your working code for the curl left to right? thanks in advance

ADD
I added some source code in my answer. I hope it helps you out.
Dimitris
A: 

Dimitris can you post your source code for curl left to right ... i searched lot but didnt get any solution.Thanks in advance

rajan
+1  A: 

It's possible to do curls in any of the four directions by using a container view. Set the container view's transformation to the angle you want and then do the curl by adding your view to the container view, not your app's main view which does not have a transformed frame:

NSView* parent = viewController.view; // the main view
NSView* containerView = [[[UIView alloc] initWithFrame:parent.bounds] autorelease];
containerView.transform = CGAffineTransformMakeRotation(<your angle here, should probably be M_PI_2 * some integer>);
[parent addSubview:containerView]; 

[UIView beginAnimations:nil context:nil];
[UIView setAnimationTransition:UIViewAnimationTransitionCurlUp forView:containerView cache:YES];
[containerView addSubview:view];
[UIView commitAnimations];
fluXa