tags:

views:

52

answers:

2

Hi, I want to call "presentmodalviewcontroller" when the iPhone / iPod Touch is rotated to landscape mode with a flip animation. When it gets rotated back to portrait, I want to present the first view again, again with the flip animation.

Weren't able to find something working on the web :(

I'm sure you can help me :) Thanks a lot ! Sebastian

+1  A: 

Try listening for the UIDeviceOrientationDidChangeNotification notification:

[[NSNotificationCenter defaultCenter] addObserver: self selector: @selector(deviceOrientationDidChange:) name: UIDeviceOrientationDidChangeNotification object: nil];

When you get on it, present your controller.

Ben Gottlieb
A: 

In your UIViewController, accept all interface orientations:

-(BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation
{
return YES;
}

And your controller will start receiving rotation messages, like:

- (void)willAnimateRotationToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation duration:(NSTimeInterval)duration

and

- (void)didRotateFromInterfaceOrientation:(UIInterfaceOrientation)fromInterfaceOrientation

Where you can react to rotation and do things like present/dismiss modal viewcontrollers.

jexe