Why portrait content displayed inside the landscape orientation? - ios

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

Related

iOS View does not change orientation on orientation change

I have a root view which contains a scroll view which contains a (content) view. The content view contains many child controls. Using the simulator, when I change orientation, none of the views, including the scroll view changes orientation. For example the image below starts out in portrait mode and all controls are played out correctly, but moving to landscape mode just shows portrait mode horizontally:
All of this was laid out using Interface Builder, so I don't have much code in the control view file besides some IB outlets to the controls.
Is there some sort of constraint that is preventing the reorientation of all the controls and views? Or do I always have to lay these out manually on orientation change?
First you need to check you have allowed the app to rotate by checking the orientations you want are ticked:
Click on the top-left corner (Show the Project Navigator)
Select the name of your project
See what is under General->Deployment Info->Device Orientation.
Adjust the tickboxes accordingly.
Update:
Also slide up on the simulator and check that rotation isn't locked for the device.
Try putting this in your AppDelegate/view controller:
- (BOOL)shouldAutorotateToInterfaceOrientation:
(UIInterfaceOrientation)interfaceOrientation
{
return YES;
}
(I don't think it's a constraint/layout issue as the status bar isn't even rotating)

iOS trigger orientation change event

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;
}

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.

iPhone Application Orientation

I forced the view in my iPhone application to always be in "landscape view." What this apparently does, though, is when iPhone is positioned vertically, the view, in landscape, is positioned vertically, as well, and half of it is missing off-screen. How would I make it so that the full landscape view is always visible (If the iPhone is held horizontally, the full landscape view is visible, and if the iPhone is held vertically, the full view is also visible, only rotated on its side)?
steps to launch app in landscape mode:
Technical Note TN2244
Launching your Application in Landscape
http://developer.apple.com/library/ios/#technotes/tn2244/_index.html
Do you have a series of layered views? In the shouldAutorotateToInterfaceOrientation() method of the base view controller, add:
return (interfaceOrientation == UIInterfaceOrientationLandscape);
It would not hurt to add that to all view controllers if the app is all landscape all the time.
Try do with this in the viewController
- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation
{
return (interfaceOrientation == UIInterfaceOrientationLandscapeRight);
}

Orientation not working in iPad

I made an iPad application in which I want to support orientation, so I've written this code:
- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation
{
//return YES;
return (interfaceOrientation==UIInterfaceOrientationPortrait||interfaceOrientation==UIInterfaceOrientationLandscapeLeft||interfaceOrientation==UIInterfaceOrientationLandscapeRight);
}
I've created a few tables in portrait mode, so when I rotate my app, the tables still comes according to portrait mode only, but the table inside my view doesn't autoresize.
You need to make sure the table view itself is set to expand and contract in both directions when autoresized - this is easiest set in IB by clicking on the table view, then clicking on the ruler sidebar header tab, then making sure that all of the autoresizing options are turned on - resizes both directions, sticks to all corners.

Resources