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);
}
Related
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)
Overview: I have a strange error where buttons on the right side of my portrait view don't work after rotating to landscape and then back to portrait again.
Detail: Here is the scenario that produces the problem. If I start in portrait, all my buttons work. I rotate to landscape (see code below) and all buttons work. I rotate back to portrait and the buttons on the right 1/4 of the screen do no respond. It's like there is a transparent view that is covering those buttons. What is strange is that if part of the button sticks out to the left of that invisible barrier, I can tap on that part of the button but not on the right part that is "under" the "cover". If I were to rotate to landscape at this point, all the buttons in landscape work. When I rotate back to portrait, that invisible "cover" has moved over to the left another 1/4 to cover roughly 1/2 of the screen. If I rotate again to landscape (all buttons always work in landscape) and then back to portrait, the invisible "cover" has moved over another 1/4 to cover 3/4 of the screen. Eventually, none of my controls respond in portrait.
Important project information:
This app is universal. The problem only happens in iPad portrait mode. The iPhone version never shows this problem in portrait (or landscape) mode.
There are only 3 views: a container view (which is the root), portrait view, and landscape view.
This app is ARC and targets 6.1. I have all the correct methods to handle rotation events.
Here is the code for rotating the views:
[portrait removeFromSuperview];
[landscape removeFromSuperview];
UIDeviceOrientation currentOrientation = [[UIDevice currentDevice] orientation];
if (currentOrientation==UIDeviceOrientationUnknown) {
currentOrientation = (UIDeviceOrientation)[[UIApplication sharedApplication] statusBarOrientation];
}
if ((currentOrientation == 0) || (UIInterfaceOrientationIsPortrait(currentOrientation))) {
[[self view] addSubview:portrait];
}
else { //landscape
[[self view] addSubview:landscape];
}
What I've tried:
The questions I found that sound remotely similar mentioned checking for memory leaks using Instruments. I tried the zombies and allocations templates and didn't see anything odd (though this is the first I've used Instruments).
EDIT: All of this is in the simulator, I haven't tested for this problem on a device yet.
Thanks for your help.
On your Simulator's menu bar select
Debug - > Color Blended Layers
Then Command + → rotate it
Then Command + ← rotate it back
There will probably be a view that gets redimensioned weirdly and covers- maybe partially - your button
i think u r not setting the frame for potrait and landscape properly that means when u rotate it the frame of some other component overlaps with the button frame and so the user interaction gets disabled
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
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.
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.