iOS trigger orientation change event - ios

I have 2 UIViews. The first supports only portrait. The second both portrait and landscape. To achieve that i change the return value of supportedInterfaceOrientations so that it gives the right orientations depending on what view i am.
When i change from screen 2 to screen 1 the view remains in a buggy landscape form, however when i rotate the device the View actually rotates to portrait and is locked there correctly. The reason for that is that when i rotate the device a rotation change event will be triggered.
my question: Is there a way to programmatically trigger a orientation change event?

I believe what you're looking for is preferredInterfaceOrientationForPresentation on view 1:
- (UIInterfaceOrientation)preferredInterfaceOrientationForPresentation
{
return UIInterfaceOrientationPortrait;
}

Related

How does the camera app prevent its toolbars from rotating while the image and its buttons do?

I noticed that when rotating the IOS camera APP its toolbars do not rotate.
The toolbars do not rotate but the content and buttons on the toolbar do rotate?
How can I achieve this effect?
It would be great if I could have some viewControllers on the same view
return shouldAutorotate = NO and some shouldAutorotate = YES
Right now I don't think doing a transformation on just the rotating views is a good option?
Is there any other way?
I am using IOS 6.
You'll need to override layoutSubviews in your UIView to position and rotate your buttons and images the way you want them. Check [UIApplication sharedApplication] statusBarOrientation in there to determine the current orientation, and rotate everything accordingly. Depending on how you've implemented your view controller, you might also need to override willRotateToInterfaceOrientation and/or didRotateFromInterfaceOrientation in your view controller to handle what happens before and after the rotation.

Why portrait content displayed inside the landscape orientation?

For a view controller, I am using the following code to restrict the orientation to landscape.
- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation
{
// Return YES for supported orientations
return UIInterfaceOrientationIsLandscape(interfaceOrientation);
}
However, the display result is not correct
It shows the portrait content inside the landscape window.
what will be the possible cause?
remove the unwanted orientation from your info.plist or just go through Autolayout in ios

How can i change portrait to landscape and back by pressing a button?

I have an ipad app which i locked to landscape left. However it has an uiwebview which can change to portrait or landscape depending on the content. I want to do that pressing on a button. Is that possible? Thanks in advance!
In general, a UIViewController will allow its UIView to rotate to follow the orientation of the device. If you don't want a rotation to occur, then you would specify your preferred/only orientation using supportedInterfaceOrientations:
So, for your need, when a button is pressed invoke supportedInterfaceOrientations: with the one and only orientation that the UIView should use. After you specified the orientation call attemptRotationToDeviceOrientation to force the transition.

Rotate UIView programmatically

I have UIViewController which supports only Portrait orientation.
In this viewController i have MPMoviePlayerController object. By default the movie controller supports both landscape and portrait orientations.
When it is in full screen mode and turned into landscape orientation the main view controller also changes his orientation, after exiting the full screen mode , the main view does not changes his orientation.
If I turn the device to portrait orientation, the main view automatically returns to the right orientation. The problem is that i dont want to rotate the main view even if the device is in landscape orientation.
Is there any way to prevent the main view to change its orientation when the movie controller rotates in full screen mode? or what is the right way to return main view into Portrait orientation.
- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation
must return NO is iOS 5 or
- (NSUInteger)supportedInterfaceOrientations {
return UIInterfaceOrientationMaskPortrait;
}
in iOS 6 in your ViewController.

UIViewController in UIPopoverController always reports as being in Portrait mode

I've got a view controller in a UIPopoverController. I want to adjust the ui based on whether or not it is in portrait orientation.
No matter what orientation my iPad is in (physical device), self.interfaceOrientation always reports Portrait. I'm logging it in -viewWillAppear: and it's always Portrait.
Why?
Use:
UIInterfaceOrientation deviceOrientation = [UIApplication sharedApplication].statusBarOrientation;
to recognize statusBar oriantation.
A view controller in a popover is always in portrait. The popover's orientation is always portrait no matter which way the device is held.
If you wish to do something different in the view controller based on the device's orientation, look at the UIApplication statusBarOrientation.
Think of the popover as following gravity. It always points down.

Resources