views:

27

answers:

1

I would like to allow the orientation to rotate as per the shouldAutorotateToInterfaceOrientation call to my view controller. However, I'd like it to do so immediately and skip the rotating animation (the one that results in the corners showing the black rotating animation while the entire view rotates.

Does anyone know if there is a way to specify that you want it to occur immediately (without animating)?

A: 

In order to do what you want, you must manually rotate (and resize) your view. There is no property you can change to easily do what you wish. Below is the code to register for device rotation events.

 - (void)viewDidLoad {
 [[UIDevice currentDevice] beginGeneratingDeviceOrientationNotifications];
 [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(orientationChanged:)
             name:UIDeviceOrientationDidChangeNotification object:nil]; 
//Whenever the device orientation changes, orientationChanged will be called

}


- (void)orientationChanged:(NSNotification *)notification
{
UIDeviceOrientation deviceOrientation = [UIDevice currentDevice].orientation;
//Based upon which orientation the device is in, update your View rotations.
//A simple view.transform = CGAffineTransformMakeRotation(whatever); will work well.
}

I believe you should remove the shouldAutoRotateToInterfaceOrientation: function altogether. You should also call [[UIDevice currentDevice] endGeneratingDeviceOrientationNotifications]; when your view unloads.

Jus' Wondrin'