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
}
}
Swipe down from the top-right corner of your screen to open Control Center. Tap the Portrait Orientation Lock button to make sure that it's off. Turn your iPhone sideways.
Method 1: Rotate Facebook Video on AndroidUpload the video to Google Photos. Choose the video, select the Share and then upload it to Google Photos. Next, tap the slide bar, then select rotate until the video is orientated as you want.
I needed that in an old project - hope it still works...
1) Register a notification:
[[UIDevice currentDevice] beginGeneratingDeviceOrientationNotifications];
[[NSNotificationCenter defaultCenter] addObserver:self
selector:@selector(detectOrientation)
name:UIDeviceOrientationDidChangeNotification
object:nil];
2) Then you can test against the rotation on change:
-(void) detectOrientation {
if (([[UIDevice currentDevice] orientation] == UIDeviceOrientationLandscapeLeft) ||
([[UIDevice currentDevice] orientation] == UIDeviceOrientationLandscapeRight)) {
[self doLandscapeThings];
} else if ([[UIDevice currentDevice] orientation] == UIDeviceOrientationPortrait || [[UIDevice currentDevice] orientation] == UIDeviceOrientationPortraitUpsideDown) {
[self doPortraitThings];
}
}
Hope that helps!
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With