Detecting rotation to landscape manually
Posted
by Thomas Joos
on Stack Overflow
See other posts from Stack Overflow
or by Thomas Joos
Published on 2010-06-09T11:34:53Z
Indexed on
2010/06/09
12:02 UTC
Read the original article
Hit count: 434
hi all,
I am working on an iPhone application based on UITabBarController and UIViewControllers for each page. The app needs to run in portrait mode only, so every view controller + app delegate goes with this line of code:
- (BOOL)shouldAutorotateToInterfaceOrientation: (UIInterfaceOrientation)interfaceOrientation { return (interfaceOrientation == UIInterfaceOrientationPortrait); }
There is one view controller where I would like to pop up a UIImageView when the iPhone is rotaed to landscapeleft. The design of the image looks landscape, although the width and height are 320x460 ( so its portrait ).
How can/should I detect this type of rotation manually, just in this specific view controller, withouth having an auto rotation on the entire view?
Thomas
UPDATE:
Thanks!
I added this listener in the viewDidLoad:
[[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(didRotate:)name:UIDeviceOrientationDidChangeNotification object:nil];
the didRotate looks like this:
(void) didRotate:(NSNotification *)notification
{
UIDeviceOrientation orientation = [[UIDevice currentDevice] orientation];if (orientation == UIDeviceOrientationLandscapeLeft) { //your code here }
}
© Stack Overflow or respective owner